0

I'm trying to run a back-up bash script in via Plesk scheduled tasks on a CentOS GoDaddy Managed Dedicated Server. I'm having a frustrating amount of trouble with this (made worse by the fact that it was working and then stopped...).

What I want to happen: I want an entire back-up of the directory I'm specifying to back-up, placed into the "backups" directory.

The script I am using: https://github.com/etiennerached/godaddy-backup-script

I have tried:

  • backupDirectory='backups'
  • filesPath='/'
  • I have also tried about all the things I can think to try in the filesPath variable. www/vhosts/subscription-name, html/vhosts/subscription-name, /var/html/vhosts/subscription-name/, /var/www/vhosts/subscription-name/, /subscription-name/, ../, html, httpdocs, and more I've forgotten.

Settings:

  • It's set to run via Plesk Scheduled Tasks. The call to the script is: /bin/bash backups/backup.sh and everything but minutes is set to *. Minutes is set to */1.
  • The script is /var/www/vhosts/subscription-name/backups as backup.sh, set to 777 permissions. The folder it's in is also set to 777 permissions. Both of these things are to make sure it's not the permissions screwing me up.
  • There is a second script, test.sh. It's in the same directory as backup.sh with the same Plesk Scheduled Tasks settings and the same permissions. It's dutifully writing to a text file every minute as directed.

I thought the script executes in the home directory of my subscription, so I don't really understand why '/' and 'backups' aren't working. But if it executes in the root directory of my server, shouldn't one of the complete path calls work?

  • 1
    Line 153: why cd $HOME/$filesPath? Why not cd $filesPath, with $filesPath being an absolute path (like /var/www/html and not www/html). – muru Oct 24 '14 at 19:01
  • Tried removing $HOME/ in all instances where it appeared, replacing $filesPath and $backupDirectory with /var/www/vhosts/subscription-name/, varying (tried with starting, trailing slashes, one or the other, both, also tried with /html/ instead of /www/). No dice. – K. W. Oct 27 '14 at 19:53
  • Not sure this is an answer so I'm commenting. I did not get the linked script working. This on ServerFault helped get a second script working. On the second script I changed tar -zcvf $filesname . to tar czvf and now the second script is working. This one also uses tar -zcvf so maybe removing the dash would have worked here as well. Thanks for the assistance: sorry I can't offer upvotes (too new). – K. W. Oct 31 '14 at 23:19
0

If you only want to backup the directory you specify this should work:

Place this script into the directory you want to backup:

#!/bin/bash

#Check if "backups" exists / if not create folder
if [ ! -d "backups" ]
then
mkdir backups
fi

#Begin Backup
#Choose if you want to use gzip or just tar

#TAR with gzip
#tar -cvfz  --exclude=backups --exclude=${BASH_SOURCE[0]} backups/backup.tar.gz .

#TAR without gzip
#tar -cvf  --exclude=backups --exclude=${BASH_SOURCE[0]} backups/backup.tar.gz .

#NOTE: We exclude "${BASH_SOURCE[0]}" because that's the name of our script,
#      so you can rename it to whatever you like
exit 0
  • 1
    Thank you. Tried this by sticking backup.sh in the home directory of the subscription and uncommenting both styles of backup, one at a time. No dice. – K. W. Oct 27 '14 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.