minor improvements

This commit is contained in:
Roger Pàmies Fabra 2024-03-26 12:32:44 +01:00
parent 9907ccef25
commit 03351da5a0
1 changed files with 5 additions and 2 deletions

View File

@ -12,6 +12,7 @@
# self-hosted server (https://gotify.net/).
#
# Tools needed: mysqldump, gzip. rsync, rdiff-backup, curl
# TODO: save current version 'sudo -u www-data php /var/www/html/nextcloud/occ config:system:get version'
###################################################################################
PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
@ -22,6 +23,7 @@ readonly GOTIFY_HOST="<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="<DB_HOST>"
readonly DB_USER="<DB_USER>"
readonly DB_PASS="<DB_PASS>"
@ -31,6 +33,7 @@ readonly NEXTCLOUD_DATA="<NEXTCLOUD_DATA>"
readonly INCLUDE_LIST="include-list"
# remote settings
readonly REMOTE_SERVER="<REMOTE_SERVER>"
# TODO: Use $(hostname) "/path/to/example/"`hostname`"/nextcloud"
readonly REMOTE_PATH="<REMOTE_PATH>"
readonly REMOTE_NC_DATA_FOLDER="files"
readonly REMOTE_NC_DB_FOLDER="db"
@ -50,8 +53,8 @@ MESSAGE="Backup task init: **"`date +"%d/%m/%Y %H:%M:%S"`"** \r"
# dump and backup db nextcloud handycat and rsync deleting origin
mysqldump --single-transaction --verbose -h $DB_HOST -u $DB_USER -p$DB_PASS $DB_NAME > $BACKUP_DB_FILE
gzip $BACKUP_DB_FILE
# TODO
# force create multiple paths (mkdir -p) if not exist with rsync trick
# TODO: force create multiple paths (mkdir -p) if not exist with rsync trick
# https://www.schwertly.com/2013/07/forcing-rsync-to-create-a-remote-path-using-rsync-path/
rsync -AaxzPh --remove-source-files "$BACKUP_DB_FILE.gz" "$REMOTE_SERVER:$REMOTE_PATH/$REMOTE_NC_DB_FOLDER"