Snapshots, backups and restore
A wrong command, a failed update or an attack can take a server down. Arianet Cloud has two tools to bring a server back:
| Snapshot | Automatic backups | |
|---|---|---|
| When it is taken | Whenever you want | Every day automatically (and manually whenever you want) |
| How long it stays | Until you delete it, even after the server is deleted | The last few copies are kept and older ones rotate out automatically |
| Cost | By the actual size of each snapshot (per GB per month) | 20% of the server plan's cost |
| Use | Before important changes; creating similar servers | Day-to-day protection against mistakes and data loss |
Both are copies of the server's main disk, and from either you can restore the same server or create a new one.
Prerequisites
- An Arianet cloud server
- For the CLI parts: the Arianet CLI with a token that has
cloud:servers:readandcloud:servers:write
1. A consistent copy of your applications
Snapshots and backups are taken from the running server's disk. Files being written at that moment (especially database files) may be half-written in the copy. To be safe, dump the database before the snapshot so a clean, restorable copy sits next to the other files:
sudo mkdir -p /var/backups/db
sudo mariadb-dump --all-databases --single-transaction | gzip | sudo tee /var/backups/db/all-$(date +%F).sql.gz > /dev/null
sync
For PostgreSQL: sudo -u postgres pg_dumpall | gzip | sudo tee /var/backups/db/all-$(date +%F).sql.gz > /dev/null.
If the server is important and a few minutes of downtime is fine, you can stop the database service or shut the server down (sudo shutdown -h now) before the snapshot.
2. Take a snapshot
In the panel: on the server page, open the Snapshots tab and click Take snapshot («گرفتن اسنپشات») (Arianet Cloud panel guide).
With the CLI:
arianet cloud servers create-image <server-id> --name before-upgrade \
--description "before apt full-upgrade" --wait
List snapshots:
arianet cloud images list --type snapshot
Each snapshot has an image value of the form snapshot:<id> used when creating or rebuilding a server, and disk_gb, the minimum disk size of a server created from it.
3. Enable automatic backups
In the panel: turn on Automatic backups («پشتیبانگیری خودکار») when creating the server, or later on the server page's Backups tab.
With the CLI:
# window hour is in UTC (0-23); 22 UTC is 01:30 Tehran time
arianet cloud servers enable-backup <server-id> --window-hour 22
arianet cloud servers change-backup-window <server-id> --window-hour 23
Without --window-hour the backup hour is picked for you. Take a manual backup now:
arianet cloud servers create-backup <server-id> --wait
List backups:
arianet cloud images list --type backup
4. Restore the same server
Restoring completely overwrites the server's current disk, and every change since that copy is lost. If you are unsure, take a snapshot of the current state first, or create a new server from the copy instead (step 5).
From a snapshot: use the server page's Snapshots tab in the panel, or rebuild the server with the snapshot image in the CLI:
arianet cloud servers rebuild <server-id> --image snapshot:<snapshot-id> --wait
From a backup:
arianet cloud servers restore-backup <server-id> --backup <backup-id> --wait
Both commands return a new root password that is printed only once; save it. SSH keys that were in the copy itself (for example ~/.ssh/authorized_keys) come back with the disk.
5. Create a new server from a snapshot or backup
Good for cloning a server, testing an update on a copy, or recovering specific files without touching the original server.
In the panel: when creating a server, in the operating system step pick the My snapshots («اسنپشاتهای من») or Backups («پشتیبانها») tab.
With the CLI:
arianet cloud servers create --name web-copy --datacenter ovh --plan 3 \
--image snapshot:<snapshot-id> --wait
arianet cloud servers create --name web-restore --datacenter ovh --plan 3 \
--image backup:<backup-id> --wait
Create the server in the snapshot's data center, with a plan whose disk is at least the snapshot's disk_gb. The copy gets a new IP; check any application that stored the IP or hostname.
6. Keep a backup forever
Automatic backups rotate out after a while. To keep a specific backup (for example the month-end one), convert it to a snapshot:
curl -s -X POST https://api.ariaservice.net/cloud/v1/backups/<backup-id>/actions/convert \
-H "Authorization: Bearer $ARIANET_TOKEN" -H "Content-Type: application/json" \
-d '{"name": "month-end"}'
When deleting a server you can also keep its completed backups as snapshots with --keep-backups (CLI) or keep_backups=true (API).
7. Managing snapshot costs
Snapshots stay after the server is deleted and keep costing. Delete old snapshots in the panel's snapshots page, or through the API:
curl -s -X DELETE https://api.ariaservice.net/cloud/v1/snapshots/<snapshot-id> \
-H "Authorization: Bearer $ARIANET_TOKEN"
arianet cloud servers costs <server-id> shows what a server's snapshots and kept backups cost. When deleting a server, --delete-snapshots also removes its unprotected snapshots.
Verify
A backup is not trustworthy until you have tested restoring it. Every so often:
- Create a temporary server from the latest snapshot or backup (step 5).
- Log in and check that the application starts and the data (for example the database dump in
/var/backups/db) is intact. - Delete the temporary server:
arianet cloud servers delete <id>.
Common errors
| Problem | Fix |
|---|---|
| Plans are disabled when creating from a snapshot | The plan's disk is smaller than the snapshot's disk_gb; pick a bigger plan. |
SSH refuses with REMOTE HOST IDENTIFICATION HAS CHANGED after a restore | The host key changed: ssh-keygen -R SERVER_IP. |
| The server cannot be deleted | Delete protection is on; turn it off first: arianet cloud servers update <id> --protection-delete=false. |
| Data on a separate volume is not in the snapshot | A snapshot only holds the main disk. Back up separate volumes separately. |
| Charges continue after deleting the server | Snapshots, separate volumes and floating IPs stay after the server is deleted; delete them from the cloud menu. |
VPS
On an Arianet VPS, automatic backups are taken every night at 2 AM, kept for 7 days, and enabled and restored from the server page's Backups tab.
Next steps
- Attach and mount an Arianet cloud volume
- Create servers with Terraform and the Arianet CLI
- Snapshots and backups in the cloud API
Protect your server
In the Arianet panel, open the Backups tab on any cloud server page and turn on daily automatic backups, or take a snapshot before every important change. No cloud server yet? Create one from Cloud server / Cloud Computing → New server and enable backups right there.