Automatic Backup - Syntax issues?

software development

#1

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:

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

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


#2

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

PATH="$HOME/bin:/usr/local/bin:/usr/bin:/bin"

If you want useful replies, ask smart questions.


#3

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 domin.sh
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
art.googlies.net - personal website


#4

That did it! Thanks for the help.