Quick and Easy Way to Backup Linux Directories to Another Server
If you want to backup all directories under /home directory on server A to another server (server B), use the following script for automated batch backup:
#!/bin/bashcd /home
for dir in $( ls )
do
if [ -d "$dir" ]; then
#echo $dir
tar czvf /disk2/$dir.tar.gz $dir
scp -P 22 /disk2/$dir.tar.gz backup@serverB.com:/backup
rm -rf /disk2/$dir.tar.gz
fi
done
You need to have a /disk2 directory for temporary tar.gz files.
You should create a public-private key pairs on server A and copy public key to server B, so you don’t need to enter password for automated backup (cron job).
Popularity: 1%


















































