LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-26-2012, 05:10 AM   #1
WoAnerges
Member
 
Registered: Apr 2012
Posts: 50

Rep: Reputation: Disabled
Question backup script question. Thank you for your help!


Hey guys,

so, I want this kind of script to get working, but I don't know, how to make it happen.



Code:
#!/bin/sh
tar czvfsp bak-$(date +%Y%m%d-%H).tgz /dir1/dir1a
mv /dir1/bak-$(date +%Y%m%d-%H).tgz /dir2/bak-$(date +%Y%m%d-%H).tgz
exit $?
Well, I don't think, this script is correct, but how to make such kind of a script?

Thank you!
 
Old 04-26-2012, 05:18 AM   #2
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,771

Rep: Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272
why do you think it is not correct? What is the problem with it?
I suggest you to use a variable for the filename:
Code:
#!/bin/sh
FILENAME=bak-$(date +%Y%m%d-%H).tgz
tar czvfsp $FILENAME /dir1/dir1a
mv /dir1/$FILENAME /dir2/$FILENAME
exit $?
 
1 members found this post helpful.
Old 04-26-2012, 05:19 AM   #3
WoAnerges
Member
 
Registered: Apr 2012
Posts: 50

Original Poster
Rep: Reputation: Disabled
Lightbulb

AWESOME!
This is what I need!
Thanks, mate.
 
  


Reply

Tags
backup, bash, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Incremental backup script question drsprite Linux - Software 2 05-19-2011 01:08 PM
Newbie trying to write a simple backup script to backup a single folder Nd for school stryker759a Linux - Newbie 2 09-16-2009 08:52 AM
how to create backup MYSQL Script to backup my database for every 1hour RMLinux Linux - Newbie 3 11-20-2008 10:13 AM
backup script question lordofring Linux - Software 7 04-18-2005 10:25 AM
Backup script question ! emailssent Programming 7 12-02-2004 07:43 PM


All times are GMT -5. The time now is 09:18 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration