Solved

small date dependent backup script needed

Posted on 1999-01-16
5
205 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ovirt 3.6 guest VM support oracle solaris 4 82
remove a combination of patterns from a file 15 71
Unix Question 19 50
aix unix tar error 3 73
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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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 get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

832 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