Welcome to Admin Junkies, Guest — join our community!

Register or log in to explore all our content and services for free on Admin Junkies.

  • Admin Junkies is proud to announce 📣 an awesome ☀️ summer special on ✍️ Content Bundles for YOUR forums! Kickstart your discussions with a Content Bundle. For the entire summer through August, use the promo code AJSUMMER 🎉 to receive 50% 🎁 off your content bundle. For example, a package that normally only costs 100 Credits will only cost 50 💰 credits. Full news here.

Regular backups and disaster recovery planning.

Joined
Jun 27, 2012
Messages
3,579
Website
www.revillution.net
Credits
246
If you are someone who has been running websites for many years, you will know how important both regular backups and having a plan should a disaster arise are.

Keeping regular backups is always advised as you never know when you could hit a problem such as cyber threats, natural disasters, hardware failures and even human errors and they can strike at any point with no warning.

Do you have a disaster recovery plan if anything happens and how do you handle your backups to ensure you do not lose any data?
 
Advertisement Placeholder
On my primary website, I did set up a remote backup in another country on another host, in addition to a standard backup in the same server. It's a balance between cost and need. Being more secure in your backups
adds cost, and asking at what point does it become worthwhile to implement?
 
Being more secure in your backups
adds cost, and asking at what point does it become worthwhile to implement?
Actually you can do secure backups without any out of pocket additional costs incurred. Just takes a little scripting to pull those backups into other locations using free tools like rsync and similar.
Creating a bash script to perform the backups and keep a rolling 7 day set on the server takes about 3 minutes of time.
The below works well if you don't mind the dump file being in a subdirectory off the web root for a short period of time. It creates a SQL dump file and then also does a full archive of the entire web directory, including the SQL dump file. After creating the archive it then deletes the SQL dump file to save space.
It's easy enough to keep outside sources from being able to discover/access the SQL by your web browser control file, especially if you place it in a subdirectory in the web root.

Bash:
#!/bin/bash
####################################
#
# Rolling 7 day backup to local directory
#
####################################

mysqldump_location="path_to_place_mysql_dump_file"

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

# What to backup.
backup_files="path_to_your_website_directory"

# Where to backup to.
dest="path_to_place_your_backup_files"

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


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

With nginx it's easy enough to protect that sub-directory with using a location directive in your main site config
Code:
location /yourdumplocation/ {
    internal;
 }

You can then automate your routine to use SFTP to access them or rsync if you are running a VPS/dedi.
This script does depend on mysqldump being available for your use as well as the archiver. Some shared hosts will probably not allow this script to work and it's more tailored towards a VPS/dedi install as that's all I have used for about the last decade.
 
Last edited:

Log in or register to unlock full forum benefits!

Log in or register to unlock full forum benefits!

Register

Register on Admin Junkies completely free.

Register now
Log in

If you have an account, please log in

Log in
Who read this thread (Total readers: 8)

Would You Rather #9

  • Start a forum in a popular but highly competitive niche

    Votes: 5 17.2%
  • Initiate a forum within a limited-known niche with zero competition

    Votes: 24 82.8%
Win this space by entering the Website of The Month Contest

Theme editor

Theme customizations

Graphic Backgrounds

Granite Backgrounds