I’m trying to learn a bit about bash-commands — more specifically about backup-scripts.
Unfortunately, I get a syntax error on the last line. I have no idea what I’ve done wrong and would appreciate any feedback on this matter.
Code:
#!/bin/sh
if [ -f $"/archive/backup-20110111.tar.gz" ]; then
echo "File already exists"
else
sudo cp /home/plepple/Documents/backup/backup-20110111.tar.gz
/home/plepple/Documents/backup/archive/backup-20110111.tar.gz
rm /home/plepple/Documents/backup/backup-20110111.tar.gz
fi
if [ -f $"/archive/backup-20110112.tar.gz" ]; then
echo "File already exists"
else
sudo cp /home/plepple/Documents/backup/backup-20110112.tar.gz
/home/plepple/Documents/backup/archive/backup-20110112.tar.gz
rm /home/plepple/Documents/backup/backup-20110112.tar.gz
fi
curdate='date +%Y%m%d'
mv /home/plepple/Documents/backup/backup.tar.gz
/home/plepple/Documents/backup/backup-$curdate.tar.gz
I tried to execute it (through bash) with:
bash backupscript.sh
All the files and directories exist.
Thanks!
should be
The same goes for
and