remote-backups.comremote-backups.com
Contact illustration
Sign In
Don't have an account ?Sign Up

PBS Removable Datastores: USB Disk Rotation

Your main Proxmox Backup Server datastore holds every snapshot, and an offsite copy protects you against a site loss. But many teams also want a third copy that is not connected at all: a USB disk that goes into a drawer or a safe. Since version 3.3, PBS can manage such a disk as a removable datastore. This post shows how to set up a rotating disk copy with two disks, and what PBS does and does not do for you.

Key Takeaways
  • A removable datastore is a normal PBS datastore with a backing device. PBS mounts it under /mnt/datastore/<name>.
  • Removable datastores came with PBS 3.3. Sync on mount came with 4.0, unmount after the sync with 4.1, and garbage collection on unmount with 4.2.
  • For a rotation, create one removable datastore per disk and one local sync job per datastore with run-on-mount and unmount-on-done.
  • Verify, prune and garbage collection jobs are skipped while the disk is not mounted. Plan for this, or enable gc-on-unmount.
  • A disk next to the server does not replace an offsite copy. It is an additional copy for the 3-2-1 rule.

What a removable datastore is

The official PBS documentation describes a removable datastore as a datastore with a backing device. You can mount and unmount it. Apart from that, it behaves like a normal datastore: it has snapshots, namespaces, permissions and jobs.

Some facts from the documentation that matter for the setup:

  • Mount point. All removable datastores are mounted under /mnt/datastore/<name>. The path that you set on creation is a path on the device, not on the host.
  • File system. Use ext4 or xfs, as with normal datastores. FAT-based file systems are not supported, because they do not support POSIX file ownership. Many new USB disks come with such a file system, so you may have to format the disk first.
  • Automatic mount. A device with only one datastore on it is mounted automatically when you attach it.
  • Several datastores per device. One device can hold more than one datastore, but the datastores cannot be nested.

This post uses PBS 4.2. Some options in it need 4.0, 4.1 or 4.2. The version for each option is in the text.

Plan the rotation

A rotation uses two or more disks. One disk is connected to the PBS host and receives the new snapshots. The other disk is stored in a different place. On a fixed day, you change the disks.

With PBS, each disk is a separate removable datastore with its own name. In this post, the names are usb-a and usb-b. Your main datastore is main. Each removable datastore gets its own sync job, which copies the snapshots from main to the disk.

Loading...
Rendering diagram...
Disk rotation with two removable datastores
One datastore per disk

Give each disk its own datastore name. The sync job, the job history and the snapshot list then show which disk has which snapshots.

Step 1: Prepare the disk

The easiest method is the web interface. Attach an empty disk, then go to Administration > Disks / Storage > Directory and create a directory with a removable datastore on it. The documentation states that PBS then partitions and formats the disk automatically.

If the disk already has an ext4 or xfs partition, you can create the datastore on it. A removable datastore refers to its device by the UUID of the file system. To find the UUID, use lsblk:

bash
lsblk -o NAME,SIZE,FSTYPE,UUID
Find the UUID of the partition

Then create the datastore with the --backing-device option. The second argument is the path on the device. It is a relative path, without a leading slash:

bash
proxmox-backup-manager datastore create usb-a usb-a \
    --backing-device <UUID-of-the-partition>
Create a removable datastore

Do the same for the second disk with the name usb-b.

Formatting deletes all data

Make sure that you select the correct disk. Formatting a disk deletes all data on it. Check the size and the model under Administration > Disks / Storage before you start.

Step 2: Sync on mount

A sync job copies snapshots from a source datastore to a target datastore. The source does not have to be on a remote server. If you leave out the remote, the source is a datastore on the same PBS host.

Two sync job options make the rotation automatic:

  • run-on-mount (PBS 4.0 and later): the sync job starts when PBS mounts the removable datastore. If one mount starts more than one job, the jobs run one after the other, in alphabetical order of their IDs.
  • unmount-on-done (PBS 4.1 and later): PBS unmounts the datastore when the sync job is finished. This option is available only together with run-on-mount.
bash
proxmox-backup-manager sync-job create usb-a-sync \
    --store usb-a \
    --remote-store main \
    --run-on-mount true \
    --unmount-on-done true
Sync job for the first disk

Create a second job for usb-b. You do not need a schedule. The job starts when you attach the disk. When the job is finished, PBS unmounts the disk, and you can remove it.

Do not add a schedule

The docs state that a scheduled sync job fails with an error when its removable datastore is not mounted. With run-on-mount, a schedule only gives you an error for the disk that is in the safe.

Choose what to copy

The sync job copies all backup groups by default. Three options control what goes to the disk:

  • --group-filter limits the job to some VMs, containers or hosts.
  • --transfer-last copies only the last N snapshots of each group.
  • --remove-vanished deletes snapshots on the disk that no longer exist on main. With this option, the disk follows the retention of your main datastore.

Think about --remove-vanished before you enable it. It keeps the disk small, but a deletion on main also deletes the snapshot on the disk at the next sync. Also note that the docs state that the protected flag of a snapshot is not synced.

Step 3: Maintenance on the disk

The documentation states that verify, prune and garbage collection jobs are skipped if the removable datastore is not mounted when they are scheduled. With unmount-on-done, the disk is mounted only for the duration of the sync. So scheduled maintenance on the disk does not run.

Garbage collection on unmount

PBS 4.2 adds the datastore option gc-on-unmount. When it is enabled, PBS runs a garbage collection before the unmount and waits for it to finish. If a garbage collection is already running, PBS waits for that run.

bash
proxmox-backup-manager datastore update usb-a --gc-on-unmount true
Run garbage collection before each unmount

Without garbage collection, chunks of deleted snapshots stay on the disk, and the disk fills up. The details are in our guide to pruning and garbage collection.

Verify from time to time

A USB disk can fail without a warning, so verify each disk from time to time. With unmount-on-done, PBS unmounts the disk right after the sync. For a verify, turn the option off for one rotation:

bash
proxmox-backup-manager sync-job update usb-a-sync --unmount-on-done false
Keep the disk mounted after the next sync

Attach the disk and wait for the sync. Then start a verify on the datastore in the web interface. When the verify is finished, unmount the disk by hand (see below) and set --unmount-on-done true again.

Unmount by hand

To remove a disk without an automatic unmount, use the Unmount button on the datastore summary page or the CLI:

bash
proxmox-backup-manager datastore unmount usb-a
Unmount a removable datastore

Both methods wait for running tasks to finish. If the unmount fails, the reason is in the task log, and the datastore stays in the maintenance mode unmounting. This mode blocks all I/O on the datastore. The docs give the commands to reset the mode: proxmox-backup-manager datastore update usb-a --maintenance-mode offline to keep I/O blocked, or proxmox-backup-manager datastore update usb-a --delete maintenance-mode to clear it.

Step 4: Restore from a disk

To restore from a disk, first turn off unmount-on-done for its sync job, as in the verify section. Otherwise PBS unmounts the disk after the sync. Then attach the disk and let PBS mount it. The datastore shows the snapshots like any other datastore, and you can restore with the usual tools. For single files, see PBS File-Level Restore: Recover Single Files.

If the PBS host is lost, you can use the disk on a new PBS installation. The docs state that you add the datastore on the new instance with Reuse existing datastore enabled, and with the same path that you set on creation. To list the datastores on a device, use:

bash
proxmox-backup-debug inspect device /dev/sdX
List datastores on a device

Test this once before you need it. PBS Restore Testing: A Practical Guide to DR Drills has a plan for such tests.

Where the disk fits in 3-2-1

The 3-2-1 rule asks for three copies on two different media, with one copy at a different site. A rotating disk gives you a copy that is offline most of the time. While it is unplugged, nothing on the network can change it.

But the disk does not replace the offsite copy:

  • The disk is often at the same site. A fire, a flood or a theft at the site can affect the server and the disk in the safe.
  • The copy is only as new as the last rotation. With a weekly change, the disk can be up to a week old.
  • The rotation depends on a person. If nobody changes the disk, the copy gets old without a warning.

Use the disk as an additional copy, next to a sync to an offsite PBS. PBS Sync Jobs: Offsite Replication explains the offsite part, and 3-2-1-1-0 Backup Strategy for PBS explains the extra offline copy.

Common mistakes

  • A FAT-formatted disk. PBS does not support datastores on FAT file systems. Format the disk with ext4 or xfs.
  • A schedule on the sync job. The job for the disk in the safe fails on every run. Use run-on-mount instead.
  • No garbage collection. Without gc-on-unmount or a manual run, deleted snapshots still use space on the disk.
  • Removing the disk during a sync. Wait until PBS has unmounted the datastore. Check the task log if you are not sure.
  • Only one disk. During each sync, the only disk copy is connected to the server. With two disks, one copy is always offline.

Wrapping up

Removable datastores make a rotating disk copy a normal part of PBS. Create one datastore per disk, add a local sync job with run-on-mount and unmount-on-done, and enable gc-on-unmount. Check the disks with a verify from time to time, and test a restore. Keep the offsite copy: the disk is a third copy, not a replacement.

Connect your PBS to an offsite datastore

The docs show how to sync your PBS with a remote-backups.com datastore, in pull or push direction.

Read the PBS setup docs

Removable datastores came with PBS 3.3. The sync job option run-on-mount came with 4.0, unmount-on-done with 4.1, and the datastore option gc-on-unmount with 4.2.

The docs name ext4 and xfs, as for normal datastores. FAT-based file systems are not supported. Many USB disks are preformatted with FAT, so you may have to format the disk.

Only when the datastore is mounted at the scheduled time. Otherwise PBS skips verify, prune and garbage collection jobs. Scheduled sync jobs start and fail with an error.

Yes. A device can hold several datastores, but they cannot be nested. The path that you set on creation identifies each datastore on the device.

No. The disk is often stored at the same site as the server, and it is only as new as the last rotation. Use it as an additional offline copy next to an offsite copy.
Bennet Gallein
Bennet Gallein

remote-backups.com operator

Infrastructure enthusiast and founder of remote-backups.com. I build and operate reliable backup infrastructure powered by Proxmox Backup Server, so you can focus on what matters most: your data staying safe.