I'm using a script to automate a backup of some of my data to a remote server. It compresses the selected folders, encrypts them with GPG, and ships them off with scp. When run from the command line, the script works fine ... when run as a cron job, though, the script fails, and the log file that it creates just ends with:
- Code: Select all
tar: -: Cannot write: Broken pipe
tar: Error is not recoverable: exiting now
Here's the script:
- Code: Select all
# !/bin/bash
tar c -PSvv --to-stdout --exclude=".thumbnails" --exclude-tag-under=".SkipMe" /home/patrick/Documents/school /home/patrick/Documents/writing 2> /home/patrick/Desktop/remote-backup.log | bzip2 -z 2>> /home/patrick/Desktop/remote-backup.log | gpg2 -r 505AB18E --batch -o "/tmp/Backup.tar.bz2.gpg" -e - > /home/patrick/Desktop/remote-backup.log && scp /tmp/Backup.tar.bz2.gpg patrickmooney@ustorage.ucsb.edu:backups 2>> /home/patrick/Desktop/remote-backup.log
if [ -d /media/Externa/backups ]; then
cp /tmp/Backup.tar.bz2.gpg /media/Externa/backups/
fi
rm /tmp/Backup.tar.bz2.gpg
chown patrick:patrick /home/patrick/Desktop/remote-backup.log
The script is run as root (i.e., installed with "sudo crontab -e"). Here's the cron line:
- Code: Select all
30 6 * * * /home/patrick/.scripts/backup-remote.sh
I've tried searching the Mint and Ubuntu forums, plus Google, but nothing useful has turned up. I've been tearing my hair out over this for a month now. Sure, I have a lot of hair, but still. Any help is appreciated.
Currently running Linux Mint Julia on an HP Pavilion dv6000, 2GB RAM, 2 GHz Intel Core Duo.






