LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Backup Rsync+SSH Server (https://www.linuxquestions.org/questions/linux-server-73/backup-rsync-ssh-server-796031/)

ctkroeker 03-17-2010 09:05 AM

Backup Rsync+SSH Server
 
I know this question has been done to death but I can't find anything that applies directly to this situation.

I have a group of around 20 production machines, which need to be backed up nightly to a Server. Since the "push" method wouldn't work to well as the machines are turned off for night, I need a pull method that issues a shutdown command after that machine is done backing up.

I've used Cron with SSH+Rsync for nightly backup push jobs, i.e. the client sends it's backup to the server
Code:

# m h  dom mon dow  command
00 01 * * * /usr/bin/rsync -avz --exclude-from=/home/client4/.exclude -r --delete -e ssh /home/client4/ server@server:/backup/client4

But I want the Server to automatically pull backups from 20 machines with no human intervention (passwordless) and without having to wade through 20 entries in cron to make little changes.

I'm thinking Cron is going to get a bit crowded and messy, so is there an easy way to script what I want? Do I still have to make a separate script for each machine, this would defeat the purpose of scripting and I could just stay with cron. What setup is best suited in this situation?

centosboy 03-17-2010 09:10 AM

Quote:

Originally Posted by ctkroeker (Post 3901848)
I know this question has been done to death but I can't find anything that applies directly to this situation.

I have a group of around 20 production machines, which need to be backed up nightly to a Server. Since the "push" method wouldn't work to well as the machines are turned off for night, I need a pull method that issues a shutdown command after that machine is done backing up.

I've used Cron with SSH+Rsync for nightly backup push jobs, i.e. the client sends it's backup to the server
Code:

# m h  dom mon dow  command
00 01 * * * /usr/bin/rsync -avz --exclude-from=/home/client4/.exclude -r --delete -e ssh /home/client4/ server@server:/backup/client4

But I want the Server to automatically pull backups from 20 machines with no human intervention (passwordless) and without having to wade through 20 entries in cron to make little changes.

I'm thinking Cron is going to get a bit crowded and messy, so is there an easy way to script what I want? Do I still have to make a separate script for each machine, this would defeat the purpose of scripting and I could just stay with cron. What setup is best suited in this situation?

try rsnapshot

http://www.cyberciti.biz/faq/redhat-...apshot-server/

http://rsnapshot.org/


it is very configurable too, quick and easy.
it is possible to have it up and running in a few minutes

ctkroeker 03-17-2010 10:27 AM

Thanks. That looks pretty good. How is this sample config? I think that would accomplish what I want, except for shutting down the machine after it's done being backed up at the end of the day...

Code:

# rsnapshot.conf

config_version 1.2

snapshot_root /backup/.snapshots/

loglevel 3
logfile /var/log/rsnapshot

exclude_file /.exclude
rsync_long_args --delete --numeric-ids --relative -avz

cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
#cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du

retain daily 7
retain weekly 4
retain monthly 12

backup client1@client1:/home/ client1/
backup client2@client2:/home/ client2/
backup client3@client3:/home/ client3/
backup client4@client4:/home/ client4/


centosboy 03-17-2010 11:38 AM

Quote:

Originally Posted by ctkroeker (Post 3901928)
Thanks. That looks pretty good. How is this sample config? I think that would accomplish what I want, except for shutting down the machine after it's done being backed up at the end of the day...

Code:

# rsnapshot.conf

config_version 1.2

snapshot_root /backup/.snapshots/

loglevel 3
logfile /var/log/rsnapshot

exclude_file /.exclude
rsync_long_args --delete --numeric-ids --relative -avz

cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
#cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du

retain daily 7
retain weekly 4
retain monthly 12

backup client1@client1:/home/ client1/
backup client2@client2:/home/ client2/
backup client3@client3:/home/ client3/
backup client4@client4:/home/ client4/


use rsnaphot -t <weekly|daily|hourly|monthly> to test your config.

as for shutdown, you can add this as a sep cron on the server itself...?

ctkroeker 03-17-2010 01:08 PM

Yeah, I guess I could do it individually on every machine, or I get Wake on Lan. Thank you!

centosboy 03-18-2010 03:58 AM

Quote:

Originally Posted by ctkroeker (Post 3902099)
Yeah, I guess I could do it individually on every machine, or I get Wake on Lan. Thank you!

or add that bit to the rsnapshot.conf file....the backup_script option...check the examples

ctkroeker 03-18-2010 05:55 AM

I was wondering if that would work, but how does the script know which machine to /sbin/shutdown -h now?

centosboy 03-18-2010 10:18 AM

Quote:

Originally Posted by ctkroeker (Post 3903002)
I was wondering if that would work, but how does the script know which machine to /sbin/shutdown -h now?

add a line for backup_script

something like

Code:

backup_script /usr/sbin/ssh user@server "shutdown -h now"
underneath the relevant backup line.

check the examples in /etc/rsnapshot.conf and test first.....with any commands...other then shutdown of course :)


All times are GMT -5. The time now is 12:31 AM.