I am trying to create a backup of a remote server. This is my configuration:
Server1 (webserver) Server2 (backupserver)
This is my little script. It starts from the server2:
#!/bin/bash date=`date +%F` basepath=/var/backup webfolder=$basepath/$date/websites/ for f in $(ssh root@server1 "ls -l /var/www/ | egrep '^l'") do if [[ $f = *.* ]] then echo "processing $f "; ssh root@server1 "tar zcf - /var/www/$f/web/" > $webfolder/$f.tar.gz fi done;
The problem is that it is too slow! How have I to speed up this script?
I have already used the Rsync without success. This is the command that I use:
/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded \ --rsh="/usr/bin/ssh -p 22" firstname.lastname@example.org:/var/www \ /home/backups/daily.0/webserver/
The servers are connected by a Dell Gigabit Switch. Both servers have the Gigabit network card. They are in the same subnet.
At the end, and thanks to the suggestions I have followed this path:
- Install rsync in all the debian box
- Install rsnapshot in the backup server
- Configure rsync deamon in the debian box (excluding the backup server)
- Set the rsnapshot cron configuration file
Waiting the first time a lot of time for the first backup.
Distro: Debian Servers