1

I have a large Drupal7 website on a shared Hostgator server, and I cannot do automated backups because I always run out of resources.

I've tried 2 methods:

1) I first built my own CLI bash file and I set up a cron job to execute it every night. The cron job emails me the output, and it never finishes and it says it ran out of resources. It was to just save the backup to the same machine.

2) I installed the Backup and Migrate module for Drupal and set up an FTP account on a seperate server on a seperate network to send the backup to. When I try it, after a minute it goes to an Error 500 screen. There's an advanced option for choosing to use CLI tools (it says this is better for larger sites) but after several minutes it went to an Error 405: Not Allowed page.

Does anybody have any advice?

Thanks!

1 Answer 1

4

According to this tutorial hostgator shared hosts can get ssh access so 2 of the solutions below assume ssh access ha been setup properly (the setup of ssh is beyond the scope of these forums)

This is also a general solution as most shared hosts nowadays have ssh access

1. using command line

# go to root directory
cd httpdocs

# dump database
mysqldump -u USERNAME -p'PASSWORD' DATABASENAME > database.sql

# zip the whole drupal directory
zip -9 -qr html.zip .

2. Using drush

setup drush (done once)

# get drush
wget http://files.drush.org/drush.phar;
# if above does not work go to and get the link to latest version .phar from
# https://github.com/drush-ops/drush/releases
# wget https://github.com/drush-ops/drush/releases/download/8.1.16/drush.phar

# make it executable
chmod +x drush.phar;

# move it to home directory or any other directory
mv drush.phar ~/drush;

# go to that directory
cd ~

# find out the path to the directory
pwd
# the output would look similar to this
# /home/your_user

# edit the following file 
nano .bashrc
# or 
# nano .bash_profile

# add this the end of the file
alias drush='/home/your_user/drush';

# use the alias you just setup
source ~/.bashrc;

using drush

# after setting up drush 
# go to root directory
cd httpdocs
# dump the database
drush sql-dump > database.sql
# zip the whole drupal directory
zip -9 -qr html.zip .

3. if no ssh present you will need to use cpanel, plesk or another control panel

database backup (one of the following)

  • go into cpanel and find phpmyadmin go into your database and start the export process
  • some panels will have under databases a way to backup a database without getting into phpmyadmin

files backup

  • go into file manager and find the root directory (public_html or httpdocs) and zip the folder

Notes

More on drupal backup

If memory runs out on any of the previous solutions perhaps you ought to upgrade your plan or move to a vps/dedicated/cloud hosting solution

if none of the above works and the support is not willing to help you set a way to backup your site get out of that host they are not worth the money that you spend

4
  • Thank you! I can't think of a better answer then this. I set up SSH years ago but haven't set up Drush yet, been putting it off. I'll try Drush but I bet it will run into the same memory limit problem. Also, could you help me with another question I posted yesterday? superuser.com/questions/1290367/… Jan 31, 2018 at 14:53
  • you are welcome ... I am not that familiar with your other question though ... perhaps might need a little revising/clearing things up to get some love
    – GiorgosK
    Jan 31, 2018 at 15:52
  • 1
    When using drush IMHO it's better to use the archive-dump command that backup code, files, and database into a single file. See drushcommands.com/drush-8x/core/archive-dump.
    – sanzante
    Jan 31, 2018 at 15:58
  • 1
    @sanzante thanks, I was actually not aware of this command. Feel free to revise the answer ...
    – GiorgosK
    Jan 31, 2018 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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