my server is using CentOS 5.5 (which is almost Red Hat Linux).
I want to backup a set of pictures into time-stamped files. This code would work:
z_cmd1=$(tar cvzf /home/user1/public_ftp/misc/pics_20100925_142230.tar.gz /home/user1/public_html/misc/_pics_var/F???????.jpg)
echo "tar output =[${z_cmd1}]"
but of course I want the time stamp to be automatic.
The following code does not work. Somehow, the third line (the one with the tar) fails. 'tar' does something, but it does not create any file at the expected destination folder. Why?
z_fname=$(date +"/home/user1/public_ftp/misc/pics_%Y%m%d_%H%M%S.tar.gz")
echo "File name =[${z_fname}]"
z_cmd1=$(tar cvzf ${z_fname} /home/user1/public_html/misc/_pics_var/F???????.jpg)
echo "tar output =[${z_cmd1}]"
Thank you.
verbose flag set, what does it say?set -xvis often helpful in debugging shell scripts.tardoes something. What does it do? What error messages do you get? What is output when you echo${z_cmd1}? Even though it doesn't appear to be necessary in this case, it's a good idea to quote variables that contain filenames.tarfails horribly because I don't have a/homedirectory on my machine, let alone the directories underneath it. Why are you capturing the output oftarlike that? Why not just let it run? And you might want to capture the errors too.