Forum backups, trust your provider or take control?

greenhost.cloud

Reputable
Joined
Apr 16, 2024
Messages
183
Reaction score
36
FP$
526
Are you willing to bet your forum on your hosting provider's backup reliability? Or will you seize the reins and implement your own backup strategy?
 
I've seen multiple sites lost forever because of a backup failure on the part of a host so I always make my own. I also periodically restore to a test site to ensure my backups are actually viable, something I suspect some hosting companies rarely do.
 
I tend to make my own backups of my websites, you just never know if and when hardware failures might occur and your host my lose your backups. I've seen websites having to revert back to old backups because it was the only backup available via their host due to issues.
 
Easy enough to do for those with shell access (usually a VPS/dedi). Copy/paste the below code into a file (I call mine xf_backup.sh) and then set it so that it is executable. Then add it into your cron jobs using crontab -e as the appropriate user that has access to the directories.

Code:
#!/bin/bash
####################################
#
# Backup to NFS mount script.
#
####################################

mysqldump_location="/path/to/site/root/directory/SQL/dump/folder"

/usr/bin/mysqldump --opt DB_NAME_HERE --single-transaction --default-character-set=utf8mb4 > $mysqldump_location/your_domain.SQL


# What to backup.
backup_files="/path/to/your/site/root/directory"

# Where to backup to.
dest="/path/to/nfs/mount/location/or/local/directory"

# Create archive filename.
day=$(date +%A)
archive_file="your_site_name-$day.zip"

# Backup the files using ZIP.
zip -8 -r $dest/$archive_file $backup_files
rm -f $mysqldump_location/your_domain.SQL

My local system backs up to an NFS mount on another VPS used for storage. Then I h ave a process at home that I SFTP to that server from my desktop and download them locally and then rsync to the two NAS servers I have running locally.
My mySQL dump file goes into a subdirectory that is not accessible via the HTTP server, but is distinctive enough it is easy to find when restoring.
The above script will give you a rolling 7 day full backup. The script can be easily modified to name the backups by date instead of day and then write a small script to run via a CRON job that keeps the most recent number of days you want.

Code:
#!/bin/bash

BACKUP_DIR="/path/to/nfs/mount/location/or/local/directory"  # Replace with your backup directory you are using
RETENTION_DAYS=14 # Number of days you want to keep backups for

find "$BACKUP_DIR" -type f -mtime +"$RETENTION_DAYS" -exec rm {} \;
is a script I used to use to do a 14 day retention.
You could probably use logrotate to do similar, but for me it was easier using a script and crontab.
 
Easy enough to do for those with shell access (usually a VPS/dedi). Copy/paste the below code into a file (I call mine xf_backup.sh) and then set it so that it is executable. Then add it into your cron jobs using crontab -e as the appropriate user that has access to the directories.

Code:
#!/bin/bash
####################################
#
# Backup to NFS mount script.
#
####################################

mysqldump_location="/path/to/site/root/directory/SQL/dump/folder"

/usr/bin/mysqldump --opt DB_NAME_HERE --single-transaction --default-character-set=utf8mb4 > $mysqldump_location/your_domain.SQL


# What to backup.
backup_files="/path/to/your/site/root/directory"

# Where to backup to.
dest="/path/to/nfs/mount/location/or/local/directory"

# Create archive filename.
day=$(date +%A)
archive_file="your_site_name-$day.zip"

# Backup the files using ZIP.
zip -8 -r $dest/$archive_file $backup_files
rm -f $mysqldump_location/your_domain.SQL

My local system backs up to an NFS mount on another VPS used for storage. Then I h ave a process at home that I SFTP to that server from my desktop and download them locally and then rsync to the two NAS servers I have running locally.
My mySQL dump file goes into a subdirectory that is not accessible via the HTTP server, but is distinctive enough it is easy to find when restoring.
The above script will give you a rolling 7 day full backup. The script can be easily modified to name the backups by date instead of day and then write a small script to run via a CRON job that keeps the most recent number of days you want.

Code:
#!/bin/bash

BACKUP_DIR="/path/to/nfs/mount/location/or/local/directory"  # Replace with your backup directory you are using
RETENTION_DAYS=14 # Number of days you want to keep backups for

find "$BACKUP_DIR" -type f -mtime +"$RETENTION_DAYS" -exec rm {} \;
is a script I used to use to do a 14 day retention.
You could probably use logrotate to do similar, but for me it was easier using a script and crontab.
That was a great method. I like to see the owner of a brand, business, blog, or any other website value the work they do and make sure their efforts are not wasted.
 
No I am not. I rather not leave my site backup to chance. If I lose my forum, it'd be very hard to rebuild from scratch.
 
That was a great method. I like to see the owner of a brand, business, blog, or any other website value the work they do and make sure their efforts are not wasted.
Simple set of scripts that those that run on a VPS or dedicated server seem to ignore. There is WAY to much preference given to control panel/hosting provider backups. When you get bit in the ass, don't whine to others because you as an admin did not do due diligence. Backup security ultimately is NOT your providers responsibility, but yours. If you screw the pooch, that is entirely upon you. Don't whine to others because you were, in the end run, too stupid to integrate an adequate backup processes.
Those of you on shared hosting... as far as I as am concerned you are at your own mercy.
Now, I do have a site that I am willing to expound on your options at. But in reality, it's not here.
 
No I am not. I rather not leave my site backup to chance. If I lose my forum, it'd be very hard to rebuild from scratch.
We got you. don't worry.

Simple set of scripts that those that run on a VPS or dedicated server seem to ignore. There is WAY to much preference given to control panel/hosting provider backups. When you get bit in the ass, don't whine to others because you as an admin did not do due diligence. Backup security ultimately is NOT your providers responsibility, but yours. If you screw the pooch, that is entirely upon you. Don't whine to others because you were, in the end run, too stupid to integrate an adequate backup processes.
Those of you on shared hosting... as far as I as am concerned you are at your own mercy.
Now, I do have a site that I am willing to expound on your options at. But in reality, it's not here.
It's all about taking charge of your backups, especially when you're running your own server.
 
Back
Top Bottom