BASH – copy backups from a remote server to your computer
Backups for the remote server should be created continuously and moved to an alternate storage location. It is advisable to do all this automatically in the cloud storage. But sometimes you want to have the same copy on your computer.
Here they will not be distracted by creating backups on the server.
Copying the site archive
Create a file backup-site.sh, make it executable:
Script for backing up the archive with the site of today:
# View the contents in the backup directory:
# ssh root@111.111.111.111 ls / home / backups / sites
# Today’s number for the file template:
today= $(date +%Y.%m.%d)
# 2024.10.20-sites.tar.gz
today=$ today‘-sites.tar.gz’
# Copies today’s backup file:
scp root@111.111.111.111:/home/backups/sites/$ today ~/Library/“Mobile Documents”/com ~ apple ~ CloudDocs/Backups/111.111.111.111/sites/
Then you can open it in the terminal and copy to the selected folders will start.
Copying the mysql archives
Script for backing up archives with mysql:
# Copy from the backup directory to the backup directory on the computer
scp -r root@111.111.111.111:/home/backups/db ~/Library/“Mobile Documents”/com ~ apple ~ CloudDocs/Backups/111.111.111.111/db