Solved

small date dependent backup script needed

Posted on 1999-01-16
5
204 Views
Last Modified: 2010-04-21
I would like a small bash script which will allow me to backup in to a tar.gz file all the files on a system modified after 14 January with exception of the files in /opt and /home/web.  Thanks in advance, Nicholas waltham
0
Comment
Question by:nwaltham
  • 2
  • 2
5 Comments
 

Expert Comment

by:jji
ID: 2009244
Hmm, something like
(find / -mtime 2 -print|grep -E -v ("/opt"\|"/home/web"))|gzip >backup.tar.gz

might work.
0
 

Author Comment

by:nwaltham
ID: 2009245
Thanks - I didn-t type that in, but I guess it needs a call to the tar program too....
0
 
LVL 3

Accepted Solution

by:
mliberi earned 30 total points
ID: 2009246

#  generate the list of the files to be backed up
touch -t 01140000 /tmp/today
find / -newer /tmp/today | egrep -v "/opt|/home/web" >/tmp/filelist
rm -f /tmp/today

# if your tar supports -L option (read files to be tared from a file)
tar -cvf - -L /tmp/filelist | gzip >tar0114.tar.gz

# if your tar doesn't support reading file list you can try
tar cvf - $(cat /tmp/filelist) | gzip >tar0114.tar.gz
# but if the filelist is greater than command line max size you will receive an error

# you could obviously use cpio instead
cpio -o </tmp/filelist | gzip >cpio0114.cpio.gz

# in many cases you can pipe the list command generator with tar or cpio command
# without saving the list to a file
rm -f /tmp/filelist

0
 

Expert Comment

by:jji
ID: 2009247
Whops, forgot the tar part :)
(find / -mtime 2 -print|grep -E -v ("/opt"\|"/home/web")|tar cf -)|gzip >backup.tar.gz

This should work...
0
 

Author Comment

by:nwaltham
ID: 2009248
Just the job. Thank you very much
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question