Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 09-18-2009, 08:22 AM   #1
Registered: Dec 2004
Location: Trondheim, Norway
Distribution: kubuntu 10.04
Posts: 308

Rep: Reputation: 31
backup script

I am working on a backup script to back up my /home onto a different disk. and then tarzip the copy. I was planning something like this:

copy home to backup
tarzip backup

Just this I could experiment until it works, but there are a few (big) files in the firefox profile I do not need a backup of, how can I exclude these? I want to keep my bookmarks database and addons, so I do not want to exclude the whole .mozilla folder.

I plan to execute the script through crontab, and in case of major changes, manually. if the partition with the backups gets full, I will delete manually.
Old 09-18-2009, 08:32 AM   #2
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
Would rsync's exclude work for your situation?


Old 09-18-2009, 08:49 AM   #3
Registered: Dec 2004
Location: Trondheim, Norway
Distribution: kubuntu 10.04
Posts: 308

Original Poster
Rep: Reputation: 31
it might. how would I do it? create a file with the unwanted files and use --exclude-from? also, does rsync by default remove from the backup files that have been deleted at the source?
Old 09-18-2009, 08:56 AM   #4
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Both tar and rsync have an exclude option. Rsync can delete files in the destination which have been deleted in the source. But reading the man page (man rsync is much quicker than asking here.

Old 09-18-2009, 09:05 AM   #5
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
You can use several command line excludes using

--exclude <filename_here>

Or you can use the --exclude-from and populate a file with the names you want to work with, but refer to the manual for rsync on the syntax of this file. Also you would have to use the --delete command line option if you want to delete files that are no longer on the source, otherwise it would not delete them.

I hope this helps.



Last edited by fordeck; 09-18-2009 at 09:10 AM.
Old 09-18-2009, 09:05 AM   #6
Senior Member
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
Why are you making a backup of your data and then making a tar of that backup? Do you really need 2 backups? If so, rsyncing the directory can be done with:

rsync -av --delete /home/user /path/to/other/disk
Then you can tar it up. The --exclude option to tar CAN be used to exclude all but the wanted files from your .mozilla directory, but that would probably prove cumbersome. It may be easier to make a mozilla-bkup directory (name it what you will) and then copy the few files out of .mozilla to it and then exclude the entire .mozilla directory. You can also just skip the creation of the live backup (the one created w/ rsync) and just tar your home directory to the alternate disk (unless you really need a live copy and a tar).


Old 09-18-2009, 09:14 AM   #7
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 404Reputation: 404Reputation: 404Reputation: 404Reputation: 404
Just note that, if you backup the files while they are being modified you risk getting an inconsistent backup, that will warn you at the end in a very fuzzy way, I don't know how does rsync handles this. You should do this while the user is not logged in, and much better, with the /home volume mounted as read only.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie trying to write a simple backup script to backup a single folder Nd for school stryker759a Linux - Newbie 2 09-16-2009 08:52 AM
Backup script nasser00 Linux - Newbie 2 07-22-2009 12:00 AM
Need help with script to organise files into folders as part of DVD backup script jasybee2000 Linux - Newbie 5 06-15-2009 07:29 PM
how to create backup MYSQL Script to backup my database for every 1hour RMLinux Linux - Newbie 3 11-20-2008 10:13 AM
Backup Script imsajjadali Linux - General 7 01-28-2004 03:30 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:14 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration