PDA

View Full Version : [ubuntu] Regular backup by date. Please correct me the command



Bullz3y3
March 10th, 2012, 05:05 AM
I've created a script for backup up my Zimbra folder according to this

http://www.youtube.com/watch?v=xhUksAhpBxw&feature=relatedBut exact command doesn't seem to work on ubuntu. here's the script


!/bin/bash
service zimbra stop

cp -rp /opt/zimbra /zimbkp/'date+%d%m%Y'/

service zimbra start
The copied folder will names as "date+%d%m%Y" not the date I require. Please help :(

athampan
March 10th, 2012, 08:50 AM
You need to use backquotes:


cp -rp /opt/zimbra /zimbkp/`date+%d%m%Y`


Please note the backquote "`" instead of the single quote "'"

codemaniac
March 10th, 2012, 08:55 AM
Wrapping 'date+%d%m%Y' in single quotes prevents shell from understanding the special meanings of command and symbols .You need use command substitution as suggested by athampan above .Below syntax you can also use :


cp -rp /opt/zimbra /zimbkp/$(date+%d%m%Y)