Automatic Backup - Syntax issues?

software development


I followed matttail’s great write-up on automatic backups, but I’m getting an error when I execute the bash:

: No such file or directorycd: /home/larrywhitt/.snapshot/nightly.0/

If I copy and paste that cd command directly, I find the nightly.0 directory without any trouble. Here’s my complete script:

suffix=$(date +%y%m%d)
cd /home/larrywhitt/.snapshot/nightly.0/
tar -cf /home/larrywhitt/backups/archives/whisperinghope.$suffix.tar

I’m not familiar with bash scripts, so I hope I’m just doing something stupid.


Add this as the second line of the script, just below #!/bin/bash:


If you want useful replies, ask smart questions.


From your errror message alone I would have guess you had “cd” in your bash script twice, but that’s obviously not the case. use the program nano to open then file on your server (from ssh) as such:
nano -w
and put an extra line between the $suffix line and the cd one. Press ctrl and o at the same time to save and ctrl and x at the same time to exit. Then try running the command and see if you still get the error.

–Matttail - personal website


That did it! Thanks for the help.