shell script backup system

The place to post if you need help or advice

Moderators: ChriThor, LXF moderators

shell script backup system

Postby mmorenopc » Tue May 31, 2005 4:49 pm

Hi all!!, I have being trying an script I found in a magazine to put in place a simple way to incrementaly backup files in a directory, i have tryied all sort of combination but the error persist, is something with xargs but i can see it

the script is:

find /home/office/ -newer /home/backup/office-backup-`date -I -d yesterday`.tgz \! -type d | xargs tar -zcvf /home/malcolm/office-date -I.tgz

And for more than i check what coung be wrong I can't see it and i get this error message

Any idea what migh be wrong ?

xargs: unmatched single quote

Thanks a lot a the force be with you !!
Posts: 1
Joined: Tue May 31, 2005 4:41 pm

RE: shell script backup system

Postby nelz » Tue May 31, 2005 6:56 pm

Try this

Code: Select all
find /home/office/ -newer /home/backup/office-backup-$(date -I -d yesterday).tgz \! -type d | xargs tar -zcvf /home/malcolm/office-$(date -I).tgz

$() is more readable than backticks, once you switch to those, you see you left them out of the archive name.

This will work provided none of your filenames include spaces, or any other shell reserved characters. xargs falls over on those. A more robust solution would be

Code: Select all
find /home/office/ -newer /home/backup/office-backup-$date -I -d yesterday).tgz \! -type d -exec tar -cf /home/malcolm/office-$(date -I).tar "{}" \;
gzip /home/malcolm/office-$(date -I).tar
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
Site admin
Posts: 9047
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Return to Help!

Who is online

Users browsing this forum: Google [Bot] and 0 guests