LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-06-2006, 08:11 AM   #1
dotancohen
Member
 
Registered: Dec 2004
Location: Haifa
Distribution: Fedora Core 4, Kubuntu
Posts: 235

Rep: Reputation: 32
Simple backup script


I've been looking for a backup solution, and I'm not really happy with any software that I see. So I'm trying to find a variant of "cp" that would just copy everything in /home/user/ that has been changed in the past X days to /home/user/backup including hidden files. I would then just burn ~/backup to a CD-R. I can't get a handle on the syntax, though. How is this done?

Thanks.
 
Old 06-06-2006, 08:57 AM   #2
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
Change the -1 mtime option to adjust the modified date. -2 will be two days ago, -3 three days, etc... You'll want to do a fullbackup and

Putting the backup directory under /home/user creates a problem with the find. It's best not to put it there.

Code:
#!/bin/sh

NEWDIR="/tmp/backup"

for i in `find /home/user -type f -mtime -1`; do
  DIR=`dirname $i`
  DEST=$NEWDIR/$DIR
  mkdir -p $DEST
  cp -a $i $DEST
done
You may want to look at rsync using the timestamp options, even for local copies. It will be a bit more robust.
 
Old 06-06-2006, 12:22 PM   #3
Electro
Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Use dar. I recommend using DVD instead of CD for backups because DVD disc includes ECC which CD do not have.

As with all backups, you will have to do a full backup so it can compare it to any modified or new files. Also test the backups on another system.
 
Old 06-07-2006, 07:00 PM   #4
dotancohen
Member
 
Registered: Dec 2004
Location: Haifa
Distribution: Fedora Core 4, Kubuntu
Posts: 235

Original Poster
Rep: Reputation: 32
Thanks, this is just what I was looking for. I will play with tit a bit and make sure that I understand it in it's entirely.
 
Old 06-07-2006, 10:53 PM   #5
Electro
Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
I dislike when people do not or just skim posts. dar is a lot better than using cp or tar. dar can double or triple the size of a CD or DVD because you can set the minimum file size to compress and set which files to not compress. Instead of running scripts, you just specify the .darrc file.
 
Old 06-17-2006, 05:00 AM   #6
dotancohen
Member
 
Registered: Dec 2004
Location: Haifa
Distribution: Fedora Core 4, Kubuntu
Posts: 235

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by Electro
I dislike when people do not or just skim posts. dar is a lot better than using cp or tar. dar can double or triple the size of a CD or DVD because you can set the minimum file size to compress and set which files to not compress. Instead of running scripts, you just specify the .darrc file.
Well, I'd rather use cp because I want to be able to access the individual files in case of need without restoring the entire backup. Usually, my needs are for only a few files.
 
Old 06-17-2006, 02:59 PM   #7
Electro
Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
dar can extract a file if you want to with out extracting the whole file.
 
Old 06-18-2006, 11:53 PM   #8
dotancohen
Member
 
Registered: Dec 2004
Location: Haifa
Distribution: Fedora Core 4, Kubuntu
Posts: 235

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by Electro
dar can extract a file if you want to with out extracting the whole file.
I just spent some time looking at dar. While it seems an excellent program, for me it is most important that the data be stored in it's original form- only cp does that. If I have a text file, I want it stored as a text file.

Thanks for the suggestion, though.

Dotan Cohen
 
  


Reply

Tags
backup


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
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
Simple help with a backup script GraemeK Linux - Software 1 05-20-2005 11:43 PM
simple-backup-script ahmed4linux Linux - General 1 05-04-2005 07:10 PM
simple backup script needed ferret_dude Programming 4 05-24-2004 08:45 AM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM


All times are GMT -5. The time now is 02:29 AM.

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