-
Edit the script to adapt
BACKUP_DIR. Default user and database are bothapp, you may need to change that too. -
You must have SSH access to the hosts.
-
Make the script executable and try it out:
chmod +x backup.sh ./backup.sh 1.2.3.4 daily 1
./backup.sh HOSTNAME SUBFOLDER KEEP_COUNTSo, given the command ./backup.sh 1.2.3.4 daily 7, the default script will save the database app on host 1.2.3.4 to /mnt/backups/daily/backup_TIMESTAMP.dump, and keep the 7 most recent files.
Using another user or database:
PGUSER=YOUR_USER DB=YOUR_DATABASE ./backup.sh HOSTNAME SUBFOLDER KEEP_COUNTcrontab -e and add something like:
0 * * * * /home/app/backup.sh 1.2.3.4 production_hourly 24 | /home/app/logger.shbackup-daily.sh is a small utily script that doesn't actually perform a backup but copies the latest hourly with the purpose of keeping some for a longer time.
Usage:
./backup-daily.sh SOURCE_FOLDER DESTINATION KEEP_COUNTE.G. in cron:
30 0 * * * ~/backup-daily.sh production_hourly production_daily 7 | ~/logger.shbackup-sqlite.sh works the same way but streams a gzipped version of an sqlite file.
Usage:
./backup-sqlite.sh HOSTNAME CONTAINER_NAME SQLITE_FILE_PATH KEEP_COUNTE.G.
30 0 * * * ./backup-sqlite.sh n8n.myhost.com n8n .n8n/database.sqlite 7 | ~/logger.sh