Skip to content

Commit ad069a1

Browse files
committed
Add possibility to esclude directories from backup
1 parent 4a69ff0 commit ad069a1

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
.env
3+
vendor/*

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Backups a directory to S3 after gzipping it and checking if it's different from the last one.
33
This avoids to upload multiple backups that are all equals.
44

5+
You can also exclude one or more directories from the backup just adding an empty file `exclude_dir_from_backup` inside every directory.
6+
57
Image runs as a cron job by default evey minute. Period may be changed by tuning `BACKUP_CRON_SCHEDULE` environment variable.
68

79
May also be run as a one time backup job by using `backup.sh` script as command.
@@ -33,6 +35,7 @@ If you want to keep the archive files created, mount a volume on `BACKUP_TGT_DIR
3335

3436
If you want to store files on S3 under a subdirectory, just add it to the `BACKUP_S3_BUCKET` like `BACKUP_S3_BUCKET=bucket_name/subdirectory_for_storage`.
3537

38+
3639
#### Examples
3740

3841
Mount the dir you want to be backed up on `BACKUP_SRC_DIR` and run image as daemon for periodic backup:

backup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ BACKUP_DST_DIR=$(dirname "${BACKUP_DST_FULL_PATH}")
1414

1515
mkdir -p ${COMPARE_DIR}
1616
echo "Gzipping ${BACKUP_SRC_DIR} into ${COMPARE_DST_FULL_PATH}"
17-
tar -czf ${COMPARE_DST_FULL_PATH} -C ${BACKUP_SRC_DIR} .
17+
tar -czf ${COMPARE_DST_FULL_PATH} --exclude-tag-all=exclude_dir_from_backup -C ${BACKUP_SRC_DIR} .
1818

1919
if cmp -s -i 8 "$BACKUP_DST_FULL_PATH" "$COMPARE_DST_FULL_PATH"
2020
then

0 commit comments

Comments
 (0)