diff options
Diffstat (limited to 'immich/backup.sh')
| -rwxr-xr-x | immich/backup.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/immich/backup.sh b/immich/backup.sh new file mode 100755 index 0000000..91770a9 --- /dev/null +++ b/immich/backup.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# Paths +UPLOAD_LOCATION="/srv/photos" +BACKUP_PATH="/path/to/local/immich-backup" +REMOTE_HOST="user@remote-host" +REMOTE_BACKUP_PATH="/path/to/remote/immich" + + +### Local + +# Backup Immich database +docker exec -t immich_postgres pg_dumpall --clean --if-exists --username=postgres > "$UPLOAD_LOCATION"/database-backup/immich-database.sql +# For deduplicating backup programs such as Borg or Restic, compressing the content can increase backup size by making it harder to deduplicate. If you are using a different program or still prefer to compress, you can use the following command instead: +# docker exec -t immich_postgres pg_dumpall --clean --if-exists --username=<DB_USERNAME> | /usr/bin/gzip --rsyncable > "$UPLOAD_LOCATION"/database-backup/immich-database.sql.gz + +### Append to local Borg repository +borg create "$BACKUP_PATH/immich-borg::{now}" "$UPLOAD_LOCATION" --exclude "$UPLOAD_LOCATION"/thumbs/ --exclude "$UPLOAD_LOCATION"/encoded-video/ +borg prune --keep-weekly=4 --keep-monthly=3 "$BACKUP_PATH"/immich-borg +borg compact "$BACKUP_PATH"/immich-borg + + +### Append to remote Borg repository +borg create "$REMOTE_HOST:$REMOTE_BACKUP_PATH/immich-borg::{now}" "$UPLOAD_LOCATION" --exclude "$UPLOAD_LOCATION"/thumbs/ --exclude "$UPLOAD_LOCATION"/encoded-video/ +borg prune --keep-weekly=4 --keep-monthly=3 "$REMOTE_HOST:$REMOTE_BACKUP_PATH"/immich-borg +borg compact "$REMOTE_HOST:$REMOTE_BACKUP_PATH"/immich-borg |
