I can't backup my website on a shared server because memory runs out. What can I do? 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!
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 &gt; 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 &gt; 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