Solved

small date dependent backup script needed

Posted on 1999-01-16
5
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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 several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:
Suggested Courses

623 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