Brent W
Well-known member
This runs fine via command line ./backup.sh but when added to a cron the scp part does not work. It completes the tar command because the tar file exists in the directory but it doesn't scp it to the remote backup server and remove the file in the local directory.
I have private keys setup so no password is required. It works, like I said, if I manually run the script.
Code:
#!/bin/bash
PREFIX="aspies"
DATADIR="/home/nginx/domains/aspiescentral.com/public"
BACKUPDIR="/home/filebackup"
REMOTEBACKUPDIR="/home/backup/aspiescentral.com/files/"
NOW=$(date +"%d-%m-%Y")
tar -cf $BACKUPDIR/$PREFIX.$NOW.tar $DATADIR
scp $PREFIX.$NOW.tar root@10.10.10.10:$REMOTEBACKUPDIR && rm -f $BACKUPDIR/$PREFIX.*
I have private keys setup so no password is required. It works, like I said, if I manually run the script.
Last edited: