Quote:
Originally Posted by mogleyzw
Hi,
I am trying to write a backup script but keep getting an error. Here is my code
Code:
#!/bin.bash
backup_files=/home
backup_dir=/backup
date=$(date +%d-%m-%Y)
archive_files="$date.tgz"
|
OK, at this point $backup_files is "/home", $backup_dir is "/backup" and $archive_files is "25-05-2012.tgz". Then you proceed to do:
Quote:
Originally Posted by mogleyzw
|
Unless the current directory is
/, the above does nothing useful.
Quote:
Originally Posted by mogleyzw
Code:
echo "backing up $backup_files to $archive_files"
tar czvf $backup_dir/$archive_files $backup_files
echo "backup complete"
|
You're running
tar czvf /backup/25-05-2012.tgz /home, which result in:
Code:
/home/
: No such file or directory
tar: /home/user/
/home/user/.bash_history
Error not recoverable: exiting now
/home/user/backup.sh
The "Error not recoverable" message is the real problem, and my guess is it appears because the directory /backup doesn't exist.