Solved

small date dependent backup script needed

Posted on 1999-01-16
5
202 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
Comment Utility
Hmm, something like
(find / -mtime 2 -print|grep -E -v ("/opt"\|"/home/web"))|gzip >backup.tar.gz

might work.
0
 

Author Comment

by:nwaltham
Comment Utility
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
Comment Utility

#  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
Comment Utility
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
Comment Utility
Just the job. Thank you very much
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

772 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now