Prev Previous Post   Next Post Next
  #1  
Old 5th July 2012, 20:50
Diggy Diggy is offline
Junior Member
 
Join Date: Aug 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default [SOLVED] Bash script help

Hi, all.

I'm in the midst of creating a bash script to archive certain directories to a NAS device. I'm not a great script writer, and would appreciate your help. Here's what I have, so far:

#!/bin/bash
FILENAME="backup"`date -d "last month" +%Y%m`".txt"
touch $FILENAME
touch --date "2012-06-01" /tmp/start
touch --date "2012-06-30" /tmp/end
find /data/nightly_data_backup -type d -newer /tmp/start -not -newer /tmp/end -print | sort > $FILENAME
mount -t nfs netdisk219:/mnt//vol001/volume02/Archive/Database /backup
tar -czvf /backup/2012_04.tar.gz --files-from $FILENAME

How can I use variables to substitute in the dates in the commands:

touch --date "2012-06-01" /tmp/start
touch --date "2012-06-30" /tmp/end

The dates should be the begin and end dates of the preceding month from the date I run the script, and:

tar -czvf /backup/2012_04.tar.gz --files-from $FILENAME

The name of the tar file should also be the preceding month, in the format shown above.

Many thanks.

Diggy

Last edited by Diggy; 6th July 2012 at 20:22.
Reply With Quote
Sponsored Links
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot login to phpmyadmin penkku HOWTO-Related Questions 1 24th February 2011 09:26
i am having some problem ? cobro Installation/Configuration 20 30th April 2008 16:26
Cannot log onto pop3 server Debian Etch Perfect Server docean Installation/Configuration 2 19th March 2008 00:23
https protocol stops page load tjd General 7 18th November 2007 18:06


All times are GMT +2. The time now is 13:19.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.