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")