Do-It-Yourself Backups¶
In this article
Built-in Invapi Tools¶
The following tools are available for virtual servers in the Invapi control panel:
- Backups — copies of the VPS disk, created on a schedule or manually. As part of beta testing, the feature is available only for VPS in the Basic group (pico, nano, mini, and medium) in the NL (Netherlands) location; the total storage limit is 50 GB. A new server cannot be created from a downloaded backup via Invapi;
- Snapshots — a copy of the VPS disk state. A snapshot is stored on the same node as the server, and only one snapshot can be stored at a time.
These tools are convenient for quick rollbacks, but they do not replace full-fledged backups: they are not available for dedicated servers, and a snapshot resides on the same hardware as the server itself. We therefore recommend additionally backing up important data with your own tools.
The 3-2-1 Rule¶
Follow the 3-2-1 rule:
- 3 copies of your data — the working data and two backups;
- 2 different types of media or storage;
- 1 copy in another place (another server, another location, object storage).
In addition:
- keep several backup versions (daily, weekly, monthly) so that you can recover from unnoticed corruption or ransomware;
- encrypt backups if they are stored with a third party;
- test restores regularly.
Tip
To store large volumes of backups, you can use a Storage server or S3 Object Storage.
Restic and HOSTKEY S3 Storage¶
Restic creates encrypted incremental backups with deduplication and works with S3-compatible storage.
- Create an S3 storage and a bucket in Invapi and obtain the access keys — see S3 Object Storage HOSTKEY.
-
Install restic:
-
Create the file
/root/.restic.envwith the access parameters and restrict its permissions (chmod 600):export AWS_ACCESS_KEY_ID="your_access_key" export AWS_SECRET_ACCESS_KEY="your_secret_key" export RESTIC_REPOSITORY="s3:https://s3-nl.hostkey.com/bucket-name/server1" export RESTIC_PASSWORD="strong_encryption_password"Attention
Store
RESTIC_PASSWORDin a safe place outside the server. Without it, data cannot be restored from the repository. -
Initialize the repository and create the first backup:
-
Configure version retention — for example, 7 daily, 4 weekly, and 6 monthly backups:
Back up databases with a dump rather than copying the files of a running DBMS — see Creating a Database Backup and Restoration.
BorgBackup¶
BorgBackup stores backups in a repository on another server accessible via SSH, for example a Storage server. The borgbackup package must be installed on both servers.
export BORG_REPO="ssh://backup@STORAGE_IP/home/backup/server1"
export BORG_PASSPHRASE="strong_password"
borg init --encryption=repokey
borg create --stats --compression zstd ::'{hostname}-{now:%Y-%m-%d}' /etc /var/www
borg prune --keep-daily 7 --keep-weekly 4 --keep-monthly 6
borg compact
Note
In repokey mode, the encryption key is stored in the repository and protected by the passphrase. Export it with borg key export and store it separately.
Rsync and cron¶
The simplest option is a daily synchronization of directories to another server. Add a job with crontab -e:
30 3 * * * rsync -aHAX --delete /var/www/ backup@STORAGE_IP:/backup/server1/www/ >> /var/log/backup.log 2>&1
Attention
rsync with the --delete option keeps only the latest state: deleted or corrupted files will disappear from the copy the next day as well. Use restic or borg to keep multiple versions.
Scheduling with a systemd Timer¶
Instead of cron, you can use a systemd timer: it keeps a log and runs missed jobs after the server is powered on.
-
Create the script
/usr/local/bin/backup.shand make it executable (chmod +x): -
Create the service
/etc/systemd/system/backup.service: -
Create the timer
/etc/systemd/system/backup.timer: -
Enable the timer and check the schedule:
Testing Restores¶
A backup can be considered working only after a successful restore. At least once a month, run:
For borg:
Restore the database from a dump on a test server or into a separate database and make sure your application works with it.
Windows Backups¶
On Windows Server, use the Windows Server Backup feature. Install it in PowerShell as Administrator:
Create a backup of the system and data on a network share:
To run backups regularly, configure a schedule in the Windows Server Backup snap-in (wbadmin.msc) or create a task in Task Scheduler. To list the existing backups, run:
Note
When writing to a network folder, Windows Server Backup keeps only the latest backup — each new one overwrites the previous one. To keep multiple versions, use a dedicated disk or third-party tools such as restic for Windows.