From bb3e2ac6ec713770edc6ddf0ab436db65fa9d1c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20P=C3=A0mies?= Date: Thu, 2 May 2024 10:56:50 +0200 Subject: [PATCH] add backup of nextcloud dir --- backup_nc.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backup_nc.sh b/backup_nc.sh index 63ce8e0..24f80b7 100644 --- a/backup_nc.sh +++ b/backup_nc.sh @@ -23,13 +23,13 @@ readonly GOTIFY_HOST="" readonly GOTIFY_PRIORITY=5 # backup db variables readonly BACKUP_DB_FILE="nextcloud-sqlbkp-"`date +\%Y\%m\%d`".sql" -#readonly BACKUP_DIR_FILE="nextcloud-dirbkp_"`date +\%Y\%m\%d`".tar.gz" readonly DB_HOST="" readonly DB_USER="" readonly DB_PASS="" readonly DB_NAME="" # backup data variables readonly NEXTCLOUD_DATA="" +readonly NEXTCLOUD_DIR="" readonly INCLUDE_LIST="include-list" # remote settings readonly REMOTE_SERVER="" @@ -37,6 +37,7 @@ readonly REMOTE_SERVER="" readonly REMOTE_PATH="" readonly REMOTE_NC_DATA_FOLDER="files" readonly REMOTE_NC_DB_FOLDER="db" +readonly REMOTE_NC_DIR_FOLDER="dir" readonly BACKUP_PRESERVE_DAYS=60 # create include list file and set exclude logs @@ -63,6 +64,11 @@ ssh $REMOTE_SERVER 'bash -s' << EOF find "$REMOTE_PATH/$REMOTE_NC_DB_FOLDER" -maxdepth 1 -mtime +$BACKUP_PRESERVE_DAYS -print -exec "rm" -R {} \; EOF +# rdiff-backup all dir of nextcloud +rdiff-backup backup $NEXTCLOUD_DIR "$REMOTE_SERVER::$REMOTE_PATH/$REMOTE_NC_DIR_FOLDER" +# clear X days old increments of backup dir +rdiff-backup remove increments --older-than "${BACKUP_PRESERVE_DAYS}D" "$REMOTE_SERVER::$REMOTE_PATH/$REMOTE_NC_DIR_FOLDER" + # rdiff-backup all data of nextcloud OUT=$(rdiff-backup backup --print-statistics --include-globbing-filelist $INCLUDE_LIST $NEXTCLOUD_DATA \ "$REMOTE_SERVER::$REMOTE_PATH/$REMOTE_NC_DATA_FOLDER")