Repository navigation
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·74 lines (60 loc) · 4.74 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·74 lines (60 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
set -e
aws_bucket=wodby-mirroring-testing
gcp_bucket=wodby-backup-tests
# Uniform bucket-level access, which Google Cloud uses by default for new buckets, rejects object ACLs.
gcp_uniform_bucket=wodby-backup-tests-uniform
azure_container=${AZURE_BLOB_CONTAINER:-}
archive_path=/mnt/backup-$RANDOM.tar
archive_path_zip=/mnt/backup-$RANDOM.tar.gz
destination=test/test.tar
tmp_dir=${BACKUP_TEST_TMP_DIR:-/tmp/backup-tests-$RANDOM}
docker run --rm -v "${tmp_dir}":/mnt -e DEBUG "${IMAGE}" make backup-dir \
exclude="./gnumake.h;./python3.11" dir=/usr/include filepath="${archive_path}" mark=".wodby"
docker run --rm -v "${tmp_dir}":/mnt -e DEBUG -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e AWS_REGION "${IMAGE}" make upload \
provider="aws" gzip=1 \
filepath="${archive_path}" bucket="${aws_bucket}" storage_class="STANDARD_IA" content_disposition="attachment; filename=test.tar" region="${AWS_REGION}"
docker run --rm -v "${tmp_dir}":/mnt -e DEBUG -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e AWS_REGION "${IMAGE}" make upload \
provider="aws" \
filepath="${archive_path}" bucket="${aws_bucket}" destination="destination-$RANDOM.tar" region="${AWS_REGION}"
docker run --rm -v "${tmp_dir}":/mnt -e DEBUG -e GCP_SA "${IMAGE}" make upload \
provider="gcp" \
filepath="${archive_path}" bucket="${gcp_bucket}" destination="destination-$RANDOM.tar" storage_class="NEARLINE" content_disposition="attachment; filename=test.tar"
if [[ -n "${AZURE_STORAGE_ACCOUNT:-}" && -n "${AZURE_STORAGE_KEY:-}" && -n "${azure_container}" ]]; then
docker run --rm -v "${tmp_dir}":/mnt -e DEBUG -e AZURE_STORAGE_ACCOUNT -e AZURE_STORAGE_KEY -e AZURE_STORAGE_ENDPOINT "${IMAGE}" make upload \
provider="azure" \
filepath="${archive_path}" bucket="${azure_container}" destination="destination-$RANDOM.tar" \
storage_class="Cool" content_disposition="attachment; filename=test.tar"
else
echo "Skipping Azure upload test because AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_KEY, or AZURE_BLOB_CONTAINER is not set"
fi
docker run --rm -v "${tmp_dir}":/mnt "${IMAGE}" make backup-dir dir=/usr/include filepath="${archive_path_zip}"
docker run --rm -v "${tmp_dir}":/mnt "${IMAGE}" make delete filepath="${archive_path_zip}"
docker run --rm -v "${tmp_dir}":/mnt "${IMAGE}" mkdir -p /mnt/files
docker run --rm -v "${tmp_dir}":/mnt "${IMAGE}" touch -d 201512180130.09 /mnt/files/oldfile
docker run --rm -v "${tmp_dir}":/mnt "${IMAGE}" touch /mnt/files/newfile
docker run --rm -v "${tmp_dir}":/mnt "${IMAGE}" make rotate dir=/mnt/files
docker run --rm -v "${tmp_dir}":/mnt "${IMAGE}" test ! -e /mnt/files/oldfile
docker run --rm -v "${tmp_dir}":/mnt "${IMAGE}" test -e /mnt/files/newfile
docker run --rm -v "${tmp_dir}":/mnt "${IMAGE}" make import source="https://s3.amazonaws.com/wodby-sample-files/archives/export.tar.gz" destination="/mnt"
docker run --rm -v "${tmp_dir}":/mnt "${IMAGE}" make import source="https://s3.amazonaws.com/wodby-sample-files/archives/export.tar" destination="/mnt" owner=10 group=10
docker run --rm -v "${tmp_dir}":/mnt "${IMAGE}" make import source="https://s3.amazonaws.com/wodby-sample-files/archives/export.zip" destination="/mnt" owner=11 group=11
docker run --rm -v "${tmp_dir}":/mnt -e DEBUG -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e AWS_REGION "${IMAGE}" make backup-and-upload dir=/usr/include \
provider="aws" \
bucket="${aws_bucket}" destination="${destination}" storage_class="STANDARD_IA" region="${AWS_REGION}"
docker run --rm -v "${tmp_dir}":/mnt -e DEBUG -e GCP_SA "${IMAGE}" make backup-and-upload dir=/usr/include \
provider="gcp" \
bucket="${gcp_bucket}" destination="${destination}" storage_class="NEARLINE"
# Streamed uploads read the service account key from a file, as backup jobs mount it.
for bucket in "${gcp_bucket}" "${gcp_uniform_bucket}"; do
docker run --rm -e DEBUG -e GCP_SA -e BUCKET="${bucket}" -e DESTINATION="stream-$RANDOM.tar" "${IMAGE}" sh -c \
'printf "%s" "${GCP_SA}" | base64 -d > /tmp/gcp-sa.json && make -f /usr/local/bin/actions.mk backup-and-upload-stream dir=/usr/include provider=gcp key=/tmp/gcp-sa.json bucket="${BUCKET}" destination="${DESTINATION}"'
done
if [[ -n "${AZURE_STORAGE_ACCOUNT:-}" && -n "${AZURE_STORAGE_KEY:-}" && -n "${azure_container}" ]]; then
docker run --rm -v "${tmp_dir}":/mnt -e DEBUG -e AZURE_STORAGE_ACCOUNT -e AZURE_STORAGE_KEY -e AZURE_STORAGE_ENDPOINT "${IMAGE}" make backup-and-upload dir=/usr/include \
provider="azure" \
bucket="${azure_container}" destination="${destination}" storage_class="Cool"
else
echo "Skipping Azure backup-and-upload test because AZURE_STORAGE_ACCOUNT, AZURE_STORAGE_KEY, or AZURE_BLOB_CONTAINER is not set"
fi
docker run --rm -v "${tmp_dir}":/mnt -e DEBUG "${IMAGE}" sh -c 'rm -rf /mnt/*'