We now offer a backup subscription for our shared hosting customers. For more details on this plan please see the following
https://www.blacknight.com/sitebackup/
Please note that this method relies on cronjobs which only work on Linux. If you want something similar on Windows you would need to look into scheduled tasks and that is only possible on a VPS\VM or dedicated server.
To backup website contents on a weekly basis, a cron job can be setup to tar up the contents into a downloadable file.
To setup this cron job, navigate to :
Websites > domainname > More Tools > Cron Management
For your website files on Standard Linux hosting plans:
/bin/tar -czf /usr/local/pem/vhosts/$Webspace_ID/webspace/httpdocs/backup.tar.gz /usr/local/pem/vhosts/$Webspace_ID/webspace/httpdocs/$Folder_to_Backup
For your website files on Linux NG hosting plans:
/bin/tar -czf /var/www/vhosts/$$/$Webspace_ID/webspace/httpdocs/backup-`date +%d.%m.%y`.tar.gz /var/www/vhosts/$$/$Webspace_ID/webspace/httpdocs/$Folder_to_Backup
Replace $$ with the path to PHP number. (On NG hosting plans only)
You can determine the path based on the 'Loaded Configuration File' directive in a phpinfo file - as per the following:
Replace the $Webspace_ID with your webspace ID.
You can retrieve your webspace ID by selecting the appropriate subscription from the subscription dropdown menu near the top right then select the 'websites' tab. The 'webspace ID' will be in the Web Hosting column.
A dated backup of your files:
If you want a dated backup, Create a txt file and add the following to it:
Standard Linux Hosting plans
/bin/tar -czf /usr/local/pem/vhosts/$Webspace_ID/webspace/httpdocs/backup-`date +%d.%m.%y`.tar.gz /usr/local/pem/vhosts/$Webspace_ID/webspace/httpdocs/$Folder_to_Backup
Linux NG hosting plans
/bin/tar -czf /var/www/vhosts/$$/$Webspace_ID/webspace/httpdocs/backup-`date +%d.%m.%y`.tar.gz /var/www/vhosts/$$/$Webspace_ID/webspace/httpdocs/$Folder_to_Backup
Save this file to a location on the webspace and in the cron management, enter
Standard Linux Hosting plans
/bin/sh /usr/local/pem/vhosts/$Webspace_ID/webspace/httpdocs/Script_name
Linux NG hosting plans
/bin/sh /var/www/vhosts/$$/$Webspace_ID/webspace/httpdocs/Script_name
This will create a the tar file with the current date of the backup.
Replace the Folder_to_Backup with the folder within httpdocs with the folder your website content reside in.
N.B On our newer NG plans the path to the root is different, you'll need to contact support to request the path to the root folder for your specific domain.
One way to determine the path would be to use a phpinfo file. If you upload it to the root folder for your domain and call it in your browser, it will display, along with other PHP related information, the path to the root folder for the domain. It is listed as 'DOCUMENT_ROOT'.
For your database:
/usr/bin/mysqldump -h $database_hostname -u $database_username -p$password $database_name > /usr/local/pem/vhosts/$Webspace_ID/webspace/httpdocs/database_backup.sql
Replace $database_hostname, $database_username, $password, $database_name and $Webspace_ID with the relevant details. Note the lack of space between -p and the password.
NOTE: If you are running the cron on an application vault install database and do not know the database password. You will need to create a new database user and use its credentials in the cron job.
https://help.blacknight.com/entries/22943048-How-can-I-add-a-new-database-user-
These cronjobs can be set to run weekly and should create a file in your httpdocs folder, this can then be downloaded as a single file.
Comments
0 comments
Article is closed for comments.