Can I back up all the files I work with each day using tar?


 
Thread Tools Search this Thread
Special Forums Hardware Filesystems, Disks and Memory Can I back up all the files I work with each day using tar?
# 1  
Old 10-01-2006
Can I back up all the files I work with each day using tar?

Can I back up all the files I work with each day using tar?
# 2  
Old 10-01-2006
Yes you can. Use the find(1) command to generate a list of files that have been modified in the last day and use that as input to the tar(1) command. Let's assume you're in your home directory:

$ mkdir backup
$ tar cvf backup/20061001.tar `find . -type f -mtime -1 -print`


If you run this command multiple times in a day, it could find your previous backups, so you might add a grep(1) filter to remove your backups:

$ tar cvf backup/20061001.tar `find . -type f -mtime -1 -print | grep -v "^./backup/"`
# 3  
Old 10-01-2006
Thanks for the help!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Back up log files using tar

Hi, I need some help writing a perl script to tar all log file to a directory and then delete the log files. Can some one please help me on this? I m Not very good with perl scripting... Thanks KK (4 Replies)
Discussion started by: karthikk0508
4 Replies

2. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

3. UNIX for Dummies Questions & Answers

tar xzCf --mode doesn't work.

$ touch x y $ ls -l x y -rw-r--r-- 1 g660 0 Sep 26 03:38 x -rw-r--r-- 1 g660 0 Sep 26 03:38 y $ chmod 777 x y $ ls -l x y -rwxrwxrwx 1 g660 0 Sep 26 03:38 x -rwxrwxrwx 1 g660 0 Sep 26 03:38 y $ rm a.tar $ tar cvzf a.tar.gz . ./ ./x ./y ./a.tar.gz $ ls -l total 4 -rw-r--r-- 1 ... (3 Replies)
Discussion started by: volbod
3 Replies

4. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

5. Shell Programming and Scripting

to find all files created a day back

Hi Guys, My unix is SunOS. I like to find all the files which are created 1 day back. i tried the following command find . -type f -name '*.aud' -mtime +1 This gives me all the files created 48 hours back (2 days) but not one.. Can you let me know where i am going wrong. Thanks,... (8 Replies)
Discussion started by: mac4rfree
8 Replies

6. AIX

tar -xvf doesnt work

Hello Im trying to extract this file tar -xvf opt-samba-base.tar.tar tar: 0511-169 A directory checksum error on media; 0 not equal to 75420. but I get that message I tried algo with gunzip and uncompress but nothing happens gunzip -d opt-samba-base.tar.tar gunzip:... (2 Replies)
Discussion started by: lo-lp-kl
2 Replies

7. UNIX for Dummies Questions & Answers

Need to go back 1 day using the date command

I am trying to write a shell script to look at log files with dates in the file name. Now I know how to use the expr command to subtract 1 day from the other, which is simple when the dates are from the 2nd to the 31st of each month. But the problem I have is when the date turns to the 1st... (4 Replies)
Discussion started by: cfoxwell
4 Replies

8. UNIX for Dummies Questions & Answers

tar to tape and back

Howdy, I'm trying to tar some directories to tape and then extract them from tape on another machine. I was hoping someone could help me with the syntax of the tar commands. Both machines are running Solaris 8. Need to get all files and directories under the following: ... (6 Replies)
Discussion started by: pmetal
6 Replies
Login or Register to Ask a Question