diff --git a/config_template.json b/config_template.json index 348bf917f2a1b011e19523e8f5a3c2bf88685980..31d21b7a7474794ef624850821cc0ee33c4ed03a 100644 --- a/config_template.json +++ b/config_template.json @@ -6,6 +6,7 @@ "sqlPass": null, "dbNames": "all", "backupRoot": "/var/backups/sql/", - "backupRetainDays": 30 + "backupRetainDays": 30, + "rsyncDest": null } ] diff --git a/sql-backup.sh b/sql-backup.sh index 6f06180f0deb7a60bf80a8c986ae5769be44ca63..36365beef9cdb0ba534a7ccf4ff283ece0eba14a 100755 --- a/sql-backup.sh +++ b/sql-backup.sh @@ -37,6 +37,7 @@ if [ $dbNames == 'all' ]; then fi backupRoot=$(cat $configFile | jq -r '.[0].backupRoot') backupRetainDays=$(cat $configFile | jq -r '.[0].backupRetainDays') +rsyncDest=$(cat $configFile | jq -r '.[0].rsyncDest') today=$(date +"%y%m%d") @@ -70,7 +71,7 @@ do continue fi - backupPath=$backupRoot$dbName + backupPath=$backupRoot/$dbName mkdir -p ${backupPath} if [ -z $sqlPass ]; @@ -106,3 +107,8 @@ do continue fi done + +if [ ! -z $rsyncDest ]; then + echo 'INFO: Rsync destination defined. Start rsync.' + rsync -r --delete $backupRoot $rsyncDest +fi