Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

small date dependent backup script needed

Posted on 1999-01-16
5
Medium Priority
?
210 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 120 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

660 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