Best Ways to Backup and Safeguard Your Data

Updated on :October 18, 2023
By :Natalia Biloshytska

Information lies in the heart of any organization today, so there is no wonder that people are continually looking for the best solution to back up and safeguard their data.

If you have ever been in the situation when your computer crashes the day before some important deadline with all the information on it, you probably already get the point. But for the business, the risk is even higher; losing your data may damage your credibility, deteriorate your financial results, and even ruin the whole business.

security of data through backups

Data Backup Best Practices

  1. Backup is a must. Even if all the components in your server are duplicated, no one is immune to logical errors and the human factors. I saw multiple situations when a missing backup caused 100x pain than implementing a backup system. And with the critical information, you just can’t risk losing it. 

  2. Backups should be scheduled and automated. That’s the only option if you want to be able to recover the data you need and not the data you have (dated March, for example). There are tons of solutions to choose from, and I will cover some of them below.

  3. Backup should be stored on remote storage, separately from the main data. Kind of obvious, right? Well, not for everyone. Backing up your data and storing it on the same storage as your original data can be just a useless exercise if your main server is compromised. Off-server backups will remain viable no matter what happens to your main hardware, allowing you to recover your data fully. 

  4. Backup storage should be located off-site. Not a must, but it’s nice to be able to stay secure during the float or zombie apocalypse. That said, we recommend to consider using remote servers or cloud solutions, possibly with your data center provider.

  5. You should implement effective versioning. It’s pretty often when you don’t need the latest saved file, but you need an older version of it. If you store only the latest versions of the files, the chances are that you store the files with unwanted changes, corrupted by ransomware malware, and those that won’t be of help. Being able to restore multiple versions of your data is essential to providing effective disaster recovery.

  6. Secure your backups by encrypting both in-flight and at-rest. Even if you store multiple versions of the files, that won’t help if ransomware variant slyly and silently encrypts all the files. Effective and reliable encryption deteriorates the chances of this ever happening and ensures that your data will be exactly what you expect in the event you need to recover it.

  7. Test it; if the first time you are trying to restore your data is the time you already lost it, you may get an unpleasant surprise. If your data fails to restore, it’s a disaster. If your data restores successfully, but during several decades, it’s a disaster. You really need to test if your process works and how long does it take.

  8. Five years ago the best-practice for off-site storage was to make tape backups on-site and then drive the tapes to some remote facility. Probably you won’t want using this today. And even if you want, probably your vendor will stop making tapes. The rapid development of cloud and virtualized solutions forces backup solutions to evolve as well.

First Step to Data Backup - Build a Strategy

First of all, you should develop your data backup strategy. There are crucial components to plan, which are as follows.

What data should be backed up? 

Honestly, the best practice is to back up everything. But if you have significant budgetary constraints, you may consider some other options. For example, if you use cloud-based applications, you can rely on their backup system and not include the app data into your snapshot. Luckily, nowadays, technology makes storage space affordable for everyone, so soon, there will be no such issue.

cloud backup

How often you should backup your data? 

Depending on how quickly you generate data and how critical this data is, you may decide to create hourly, daily, and weekly backups. This also depends on how often your files change, but I believe that weekly is the least you should do.

Where to store backups? 

You may consider cloud storage, remote servers, virtual machines, and local storage within your organization. Of course, you can use multiple backup sources to be completely safe.

How long should backups be stored? 

You should assess the nature and needs of your business to answer this question. I recommend backing up and/or archiving not only the data that you are regularly using these days but also the data that is no longer in regular use, like your statistical data, old cases, and finished projects.

Different Types of Backups

Let's see the different types of backup.

Full Backups

It’s pretty obvious from the name that with the full backup you will create a complete copy of the data set. This is the simplest type to create and the simplest (and the fastest) type to restore from. But as usual, there are some disadvantages to it, like high network load, time-consuming process, large-capacity storage space. That is why full backups are usually run periodically, being combined with other backup types.

Incremental Backups

Incremental backups can be done when you already have a full system backup. After that is done, increments back up only the files that have changed comparing to the last backup snapshot. The biggest advantage is the high speed of the backup jobs, but the disadvantage is that if one increment in the chain is corrupted, it will be impossible to perform the full recovery.

Differential Backups

The differential backup type is an intermediary solution between the full backup and incremental backups. Similar to incremental backups, you will need to create a full backup first. But contracting to incremental backups, it will save the data that has changed comparing to the initial backup (not the last one). Thereby differential backups are somewhere in between full backups and incremental backups in terms of both backup speed and recovery speed.

What to Do When You Lose Data?

  1. The most crucial step is to stop using the affected system, drive, server to minimize the risk of overwriting the data, and further damaging the system. Just shut down the system and do not restart.

  2. Praise yourself that you bothered to implement the backup strategy. That was your lucky day.

  3. Use a separate drive to recover the data. That’s just logic. You need to recover your data fast; you are in a hurry and don’t have time to fully evaluate the situation and understand what happened. You don’t want to repeat that in minutes or hours.

cloud storage

Different Approaches to Backup

There are three main approaches to backups: file storage backups, database backups, and virtual machine backups.

File Storage Backups

For file storage backups, we use Rsync and Bacula. Rsync is a free, open-source protocol built for Unix-like systems, that provides unbelievable versatility for backing up and synchronizing data and that works just great on a small scale. 

It can be used locally to back up files to different directories as well as it can be configured to sync across the Internet to other hosts. But if choosing Rsync, you should be ready to maintain the scripts on your own. 

For most purposes, the following will suffice:

# rsync backup on remote backup server

rsync -a /backups/data1 remote_user@backup_remote_host_or_ip:/backup/data1/

# restore data from remote backup server

rsync -a remote_user@backup_remote_host_or_ip:/backups/data1/ /backups/data1/

Bacula’s centralized console lets you control all of your backup jobs and provides extended reporting. 

Bacula has great documentation, so please use it to set up the system.

Database Backups

Obviously, the solutions are different for different databases.

In this article, I will briefly cover MySQL, MongoDB, and PostgreSQL backup options.

MySQL Database Backup

The first thing you should know that MySQL backups are categorized as hot and cold.

Hot backups are online, meaning that the server continues operating, and cold are offline, meaning that the database is not available for processing queries. 

For pure InnoDB tables, we create a local hot backup with Mysqldump. We then transfer it via Rsync to the remote backup server, thereby creating cold backups for long-term storage. Usually, it’s reasonable to create daily cold backups.

Please keep in mind that mysqldump locks the database for writing requests, so we recommend running it on the slave servers. 

For local backup, you can use this simple  script (please replace %dbname% with your database name)

#!/bin/sh

cur_date=`date +%F`

backup_dir=/backups/db_backups/split

dbase=%dbname%

echo "starting dump of ${dbase} in ${backup_dir}"

mysqldump -uroot -p'XTbaseOO1234' --set-gtid-purged=OFF --insert-ignore  ${dbase} > ${backup_dir}/${dbase}.sql

echo "compressing ${backup_dir}/${dbase}_${cur_date}.tar.gz"

tar cvzf ${backup_dir}/${dbase}_${cur_date}.tar.gz ${backup_dir}/${dbase}.sql

rm -rf ${backup_dir}/${dbase}.sql

As usual, this works perfect on a small scale. But if you want to create backups at varying intervals; daily, weekly, and monthly, and need additional features such as email notification, incremental database backups, backup compression, and encryption backups, you should consider using AutoMySQLBackup, which is a commercial (and more powerful) tool.

Obviously, there is no reason to back up your data if you can’t restore it. Here is the script (again, please replace the database name and file path with your valued):

#mysql restore

mysql -uroot -p db_name < /backups/restore_file.sql

MongoDB Database Backup.

MongoDB is one of the most popular NoSQL database engines. It is recognized for being reliable, powerful, scalable, and easy to use. In this article, we'll show you how to back up, restore, and migrate your MongoDB databases.

To proceed with backups, you should first create the directory /var/backups/mongobackups with the command:

sudo mkdir /var/backups/mongobackups

And when you are done, the backup command should look like this:

sudo mongodump --db newdb --out /var/backups/mongobackups/`date +"%m-%d-%y"`

As a general rule, you should make backups when the server is least loaded. Restore function comes useful not only when data loss happened, but also when you need to migrate your MongoDB database.

By running the 'mongorestore' command, you will be able to restore the exact copy of the MongoDB database, including all the indexes and data types.

mongorestore --db newdb --drop /var/backups/mongobackups/%m-%d-%y /newdb/

mongorestore --db databasename --verbose /backup/dump

PostgreSQL Database Backup

PostgreSQL offers more advanced (and more complex) ways to back up your databases. You can research the official documentation to get to know how to set up continuous archiving and point-in-time recovery. This will maintain an archive of your database and make it possible to recover the state of the database at any point in the past.

But if you are not ready to get too deep into this, you can use these simple commands to run daily, weekly, and monthly backups and restore your data:

#BACKUP

pg_dump -U db_user -W -F t db_name > /path/to/your/file/dump_name.tar

#RESTORE

psql -U db_user db_name < dump_name.sql

Virtual Machines Backups

Virtual Machines backups are the simplest. Each VM provider makes snapshots from virtual machines (not stopping VM instance), which is really easy, efficient, and reliable. You can back up all VM data, including databases and files.

And it’s just as simple to restore the data.

Data Backup Software

Any discussion about data backups would be incomplete without the mention of data backup software. The best data backup software ensures that your data is not lost. There are a variety of software solutions available for data backup and safety. 

So, try the top data backup software such as  GoodSync, Acronis True Image, AOMEI Backupper, Carbonite, NovaBACKUP, Backblaze, and many more. 

Wrapping Up!

You can choose from a multitude of approaches and solutions to set up a data backup strategy that best fits your needs, goals, and restriction. The most important thing is to actually back up your data. And sooner or later you will consider yourself blessed for thinking of it.

Cloud service providers like Amazon and Google backup all your data, and you need not worry about these issues. But, if you do want to manage your data backups yourself, it is a good idea to go for the ready software solutions. 

Have you tried any data backup software? Don’t forget to post a review!

Natalia Biloshytska
Natalia Biloshytska

Natalia Biloshytska is co-founder and CEO of CoreQ, a DevOps consulting firm that helps digital businesses to accelerate growth by building the right infrastructure and ensuring 99.99% uptime. Natalia often acts as the primary point of contact for the new clients, bridging them and the technology team.