LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   backup script question. Thank you for your help! (http://www.linuxquestions.org/questions/linux-newbie-8/backup-script-question-thank-you-for-your-help-941821/)

WoAnerges 04-26-2012 05:10 AM

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!

pan64 04-26-2012 05:18 AM

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 $?


WoAnerges 04-26-2012 05:19 AM

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


All times are GMT -5. The time now is 08:58 PM.