Unix administration - help with backup script

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > November 2006 > help with backup script





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author help with backup script
tony

2006-10-17, 1:25 pm

I got a simple command script that copies a backup file to a server

scp -rpv root@remotehost::/var/backup/* /home/susedbbackup | mail -s "
backup status" emailaddress


How do I modify this script to check for errors or sucess, and email the
result


thanks





Michael Tosch

2006-10-17, 7:37 pm

tony wrote:
> I got a simple command script that copies a backup file to a server
>
> scp -rpv root@remotehost::/var/backup/* /home/susedbbackup | mail -s "
> backup status" emailaddress
>
>
> How do I modify this script to check for errors or sucess, and email the
> result
>
>


If "success" is exit status 0, you can use
capture=`
scp -rpv "root@remotehost::/var/backup/*" /home/susedbbackup
` ||
echo "$capture" | mail ...

If your output can grow very big, then better use a tmpfile:
scp -rpv "root@remotehost::/var/backup/*" /home/susedbbackup > tmpfile ||
mail ... < tmpfile

P.S. you better quote the * expression, so the shell
does not try to match it with the local file system.

--
Michael Tosch @ hp : com
Renato Golin

2006-11-03, 1:18 pm

Michael Tosch wrote:
> scp -rpv "root@remotehost::/var/backup/*" /home/susedbbackup > tmpfile ||
> mail ... < tmpfile
>
> P.S. you better quote the * expression, so the shell
> does not try to match it with the local file system.


If you're using -r you don't need the * anyway.

--renato
PS: have you considered rsync for backup?

--
Reclaim your digital rights, eliminate DRM, learn more at
http://www.defectivebydesign.org/what_is_drm
Raqueeb Hassan

2006-11-14, 7:33 am

<snip>

> PS: have you considered rsync for backup?


I was thinking of rsync too, specifically the snapshot style backups!
We can't think of NetApp file servers in SOHO environment, but it
serves all the purpose.

To give you a quick view, here is how to call rsync over ssh;

rsync -a -e ssh dir_for_backup/
userid@backupserver.com:/destination_dir/

Then, let cron do the dirty work for you.


--
Raqueeb Hassan
Bangladesh

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com