Back up files using Putty

DaveL

Well-known member
Hi, I currently use putty to back up my databases.
Just wondering what the command prompt would be to make a back up for the directories and files?
 
Yep! You should move these compressed backups to a separate backup server for maximum safety.
You can automate this process as well with a cron. This is what I do:

Backup database
50 3 * * 2,4,6 root cd /var/lib/mysql/ && mysqldump --max_allowed_packet=1G --single-transaction --quick --lock-tables=false -u database_user -p'DBpassword' database_name | gzip -9 > backup-`date --iso`.sql.gz

This gives a nice backup-01-21-2020.sql.gz format.

Compress forum files
30 4 * * 6 root cd /home/admin/domains/domain.com/ && tar -cvzf filesbackup-`date --iso`.tar.gz public_html/

Rsync database
20 4 * * 2,4,6 root rsync --remove-source-files -avz -e "ssh -p22" /var/lib/mysql/backup*.sql.gz root@1.1.1.1:/root/backups/

Rsync forum files
45 6 * * 6 root rsync --remove-source-files -avz -e "ssh -p22" /home/admin/domains/domain.com/filesbackup*.tar.gz root@1.1.1.1:/root/backups/files/

These should be created as files in /etc/cron.d, just add in your own things like SSH port, backup server IP, path to MySQL database and files, etc.
 
Back
Top Bottom