Before OrientDB 2.2, only full backups of a database were allowed. With 2.2 Enterprise Edition, you may now perform your backup in two different ways:
In this article, we will review the new Backup Manager, offered in Studio 2.2 EE, which allows you to schedule and perform backups using different strategies to easily execute and manage restore points.
Below is a screenshot of the Studio Backup Management Panel, which can be found in the Server Management area.
The panel is divided into two sections. On the left side, you may schedule backups, and on the right side, you’ll find a calendar where you may check executed tasks (backup or restore), the scheduled backups, and the eventual errors raised during the execution of a task.
The backup scheduler offers three different backup modes:
Once a database is selected, you may choose a preferred backup mode through the left panel, where you can also specify the output directory for your backups and specify a number of retention days for each of them. You may subsequently schedule the backups by declaring the waiting period between two sequential operations.
Using the Full Backup mode, a full backup is performed at the end of the specified period and stored in the path you specified in Settings.
Incremental Backup generates smaller backup files by only storing the delta between two versions of the database. This is useful when you execute backups on a regular basis and you want to avoid backing up the entire database each time. Let's suppose we want to execute a backup every five minutes: A first full backup will be performed, then it will be followed every five minutes by a new incremental backup, only containing the delta. The restore procedure automatically recognizes if a backup contains incremental data. But what about the restore procedure? Restoring an incremental backup creates a new database with the restored content. You cannot perform an in-place incremental restore on an existing database.
The last mode, Full + Incremental Backup, follows a hybrid approach between the first two strategies, combining them according to your criteria.
Unlike the first two strategies, to exploit this feature you must specify two different backup periods:
This is the most powerful and flexible strategy, so let’s analyze it through a simple use case in order to understand how the two modes are combined.
You can have different granularities to schedule your backups. Aside from minutes, you can choose hourly, daily, weekly, monthly, and yearly granularity. Suppose we decided to execute the full backup every day (e.g. at 3.00 a.m.) and the incremental backup every hour as shown in the example below. Obviously, the full backup period must be greater than the incremental backup period, as different settings may cause illogical behaviours.
Once the backup task is configured, you can simply flag the “Enabled” option and then press the “Save” button. From this moment forward, the scheduler is active and will work as we stated in the panel. If you want to disable the scheduler, you must unflag the “Enabled” option and then press the “Save” button again.
With these settings, a new directory containing a full backup will be added to the specified path every day. Then every hour, until the next day, only incremental backups will be performed. because we set one hour for incremental backups, we will have 23 incremental backups after the first full backup executed at 3.00 a.m. The next day at 03:00 a.m., a new full backup in another folder will be performed, and the following incremental backups will be executed according to the delta relative to this second full backup. They will be stored in this second folder. That's all. After another day we will have a third directory with an initial full backup followed by 23 incremental backups, and so on.
/tmp/backup/full-incremental | |____________GratefulDeadConcerts-1470662040018 | |____________GratefulDeadConcerts_2016-08-08-03-00-00_0_full.ibu | |____________GratefulDeadConcerts_2016-08-08-04-00-00_1.ibu | |____________GratefulDeadConcerts_2016-08-08-05-00-00_2.ibu | |____________GratefulDeadConcerts_2016-08-08-06-00-00_3.ibu | |____________GratefulDeadConcerts_2016-08-08-07-00-00_4.ibu | ... | |____________GratefulDeadConcerts-1470662340015 | |____________GratefulDeadConcerts_2016-08-09-03-00-00_0_full.ibu | |____________GratefulDeadConcerts_2016-08-09-04-00-00_1.ibu | |____________GratefulDeadConcerts_2016-08-09-05-00-00_2.ibu | |____________GratefulDeadConcerts_2016-08-09-06-00-00_3.ibu | |____________GratefulDeadConcerts_2016-08-09-07-00-00_4.ibu | ... | |____________GratefulDeadConcerts-1470662640014 | |____________GratefulDeadConcerts_2016-08-10-03-00-00_0_full.ibu | |____________GratefulDeadConcerts_2016-08-10-04-00-00_1.ibu | |____________GratefulDeadConcerts_2016-08-10-05-00-00_2.ibu | |____________GratefulDeadConcerts_2016-08-10-06-00-00_3.ibu | |____________GratefulDeadConcerts_2016-08-10-07-00-00_4.ibu | ... | ...
With this method, you’ll have a "checkpoint" for each different directory, which may be used in order to restore the database to a specific moment. You can decide whether to delete or maintain old backups. For each one, you may also exploit the incremental backup features at the same time. After three days, your calendar will look similar to the image below:
Continuing with our example, you may want to restore a specific backup. You can perform this by referring to the calendar on the right, containing info about both already-performed and scheduled tasks. Notice that you may choose three different scopes to recover our target backup event: month, week, and day.
Once the Restore Point is identified, you must simply click on it. Additional info, such as execution time and timestamp, the directory path where your backup is stored, the file name, and the file size will be provided in a new window. From this window, you may remove the backup or begin to restore data. Let’s suppose we want to restore the database to the state of 2016-08-09.
Once the “Restore Database” button is clicked, a new window will open. From here, you must select the database where you want to restore the backup: Notice you must simply declare a name, and a new empty database will be automatically created by the restore procedure. You cannot use an existing database containing data or a fresh, manually built database. Let’s choose an unused name, for example “newdb.”
You can see that all the files involved in the restore procedure are reported. The number of files used to restore your database depends on the backup mode you chose for the selected backup task. In our use case, because we chose a backup belonging to a Full + Incremental Backup schedule, all the files contained in the folder of the backup event you selected from the calendar will be evaluated. You may now press the “Restore” button and the work is done! So give it try, configuring your backup and restore tasks according to your own needs. Enjoy!