8. Backup and recovery
RAID keeps your data through a failed disk, and snapshots bring back a deleted or encrypted file. Neither survives the server itself: a fire, a theft, a power surge, or a mistake that reaches every disk. For that you need a backup: a copy somewhere else, with versions to go back to.
A good plan keeps three copies of what matters, on two kinds of storage, one of them off site. OSM gives you:
| Tool | What it does | Where |
|---|---|---|
| Backup tasks | Encrypted versions of your shared folders, home folders, apps' data and settings, on another disk, a USB drive, another server or a cloud store | Backup |
| PCs and servers | The network's Windows PCs and Linux servers backed up to this server with OSM Backup, in versions they cannot delete | Backup > PCs and servers (below) |
| Snapshots | Read-only copies of a shared folder on the same volume, instant and space-saving; immutable ones resist ransomware | Storage (Storage) |
| Replication | A shared folder's snapshots copied to another OSM server | Backup > Replication |
| Cloud tasks | A shared folder kept alike with a folder in a cloud (a sync, not a backup) | Backup > Cloud |
| The way back after an update | OSM's version before, put back by OSM itself when the new one does not start | Settings > Updates and Recovery (the update history says so) |
Backup tasks
Backup > Create makes a task. It backs up with restic: only what changed since the last run is sent, every run is a version you can restore from, and everything is encrypted before it leaves the server.
- Name the task.
- Choose where it goes (below).
- Choose what:
- the shared folders to back up, and the home folders (everyone's);
- The server's settings and accounts: the accounts with their passwords (not their two-step sign-in), the groups, the shared folders and their permissions, the file services' settings, the other settings a configuration backup holds, and the installed apps with their settings. A version that has them can rebuild a server on a new installation (below);
- The apps' data: the apps' settings, databases and files (below).
- Choose when: every day or every week at an hour you choose (02:00 by default), or by hand. A weekly task runs on Sundays; What, when and how long... in its ··· menu changes the day. Tasks run one at a time: a task that cannot start at its hour (another backup still runs, or the server was off) starts as soon as it can, the same day.
- Choose what stays: one version a day for 7 days, one a week for 4 weeks, one a month for 12 months and one a year for 2 years, by default. Older versions are deleted, and the latest one always stays.
- Give it a password of at least 8 characters.
Keep the password somewhere else. Without it nobody can read the backup, OSM included. A backup whose password is lost cannot be restored, and nobody can recover the password.
Back up now runs a task at once. The task list shows each task's last run, and whether its last test restore passed (Proved). A run that fails, or that misses folders that are not there (deleted, locked, or on a volume that is not mounted), is a notification: such a folder is left out of that run, never saved as empty, and its older versions stay.
Where a backup can go
| Destination | What you need |
|---|---|
| A folder of a volume or a USB drive | A folder on another volume or a USB drive. A backup on the same disks as the data does not survive them. |
| Another server, over SFTP | An account on that server. OSM signs in with its own key: the dialog shows it, and you add it to that account's ~/.ssh/authorized_keys. The first connection remembers the server's key. |
| An S3-compatible store | Its address (Amazon S3, Wasabi, Cloudflare R2, Backblaze B2's S3 address, MinIO...), a bucket, an access key and a secret key. |
| A restic REST server | Its address, and an account and password if it asks for one. |
An off-site destination (an S3 store, or a server at another place) protects you from what happens to the building.
The apps' data
The apps keep their own settings, databases and files in an area of the volume that is not a shared folder. A backup task with The apps' data (on by default) saves it in a version of its own, labelled The apps' data in the list of versions, next to the version of the shared folders made by the same run.
A database copied while it is being written can be unusable, so OSM reads the apps' data as it stood at one moment:
- On Btrfs and ZFS volumes, the apps are paused for about a second while OSM takes a snapshot of their data, then run on while the backup reads the snapshot. The snapshot is deleted when the backup ends.
- On ext4 volumes, which have no snapshots, the apps are paused while their data is read. This usually takes a minute or less at night, and never more than two hours. If reading takes longer, it is stopped, the apps run again, and you are told that the apps' data was not backed up (the shared folders still are). For apps with much data, a Btrfs or ZFS volume avoids the wait.
- If the backup goes to the server itself (an app of it, such as an S3 or SFTP app), or its destination does not answer while the apps are paused, the apps do not wait, since the backup would wait for them: on an ext4 volume, their data is then read while they run.
Paused apps always run again, even if the server restarts during a backup. Caches that an app makes again by itself (Jellyfin's cache, Plex's transcodes, Immich's models) are left out.
The virtual machines' disks are not part of the apps' data: see Virtual machines.
Backups that prove themselves
A backup is only as good as its restore. OSM checks every backup task on its own:
- Every month, a test restore, two hours after the task's time. Files of the latest version, picked at random, are restored into a scratch folder and compared with the files on the server (those not changed since the backup). Part of the backup's data is also read each month, so all of it is read once a year.
- A report on the 1st of each month: every task, its last run and its last test restore, as a notification and by email if email is set up. Report... shows it now.
- Test a restore now and Check the backup (reads 5 % of it) are in each task's ··· menu.
A file that does not come back, or comes back different, is an error notification.
Restoring
Files and folders
- Backup > Versions on the task, then Browse... on a version.
- Tick the files and folders to restore. Open a folder by its name; the path at the top goes back.
- Choose where:
- Back where it was: what is there now is replaced;
- Into a new folder: a folder named after the task and the date, under the folder you give (for example
/volume1/Restore). Nothing on the server is replaced.
Restoring an app's data back where it was stops the app first, and starts it again afterwards. The data comes back exactly as it was in that version: files the app wrote since are removed, so a database is never mixed with a newer journal. If the restore fails, or the server restarts in the middle of it, the data that was there is put back.
A restore needs the volume or USB drive it writes to: if it is not mounted (or the drive is unplugged), the restore stops before it writes anything, rather than fill the system disk.
The whole server, onto a new installation
When a server is lost, a version made with The server's settings and accounts brings its accounts, shared folders, files and apps back on a new installation:
- Install OSM on the new server, and make its volumes with the same names as before (Volume 1, Volume 2...).
- Backup > Open a backup of another server...: give the destination of the old backup and its password. For a backup on another server over SFTP, the new server signs in with a key of its own: the dialog shows it, and you add it to that account's
~/.ssh/authorized_keysfirst. - Versions on the task it makes, then Restore everything... on the version you want, and choose:
- The shared folders' files too;
- The apps, with their data.
OSM restores, in this order: the groups and accounts (with their passwords), the settings, the shared folders and their permissions, then the files, then the apps with their data. Accounts that exist on the new server already stay as they are; a shared folder that exists already takes the backup's description and permissions. When the old server was a domain controller, the backup's copy of the domain goes among the Domain app's copies: Domain makes the domain again from it (Domain).
It does not bring back the network, email and notifications, the backup, cloud and replication tasks, the scheduled tasks, the VPN's devices, the certificates, the firewall's lists, the password rules, or two-step sign-in and passkeys: set them up again.
Cloud tasks
Backup > Cloud keeps a shared folder and a folder in a cloud alike: WebDAV (Nextcloud, ownCloud...), S3 (AWS, Wasabi, Cloudflare R2, MinIO), Backblaze B2, SFTP, Google Drive, Dropbox, or another folder such as a USB drive.
- Which way: Upload (new and changed files go up), Mirror up (the cloud becomes like the folder, deletes included), Download, or Mirror down.
- When: every hour, every day, or by hand. Test the connection checks the settings first.
- Google Drive and Dropbox need a token: run
rclone authorize "drive"(or"dropbox") on a computer with a browser, sign in, and paste what it prints. - A task with a USB drive runs only with that drive, never with another one in its place; and no task runs while a remote folder is mounted inside its folder (a mirror would delete the other computer's files).
A cloud task is not a backup: a mirror copies deletions and damaged files too. For versions, use a backup task.
Replication
Backup > Replication copies the snapshots of a shared folder on a Btrfs volume to another OSM server: the first time in full, then only what changed. After a disaster the other server can turn the newest replica into a shared folder of its own.
- On the server that receives: install SSH in Settings > SSH. In Backup > Replication > Receive, turn on Take replicas from other OSM servers, choose the Btrfs volume that keeps them, and Add a sender with a name and the sender's key (shown on the sender, in the same page).
- On the server that sends: Replicate a shared folder: the shared folder, the other server's address and SSH port, when (every hour, every day, or by hand), and how many replicas it keeps (30 by default).
On the receiving server, Replicas here lists them, and Make it a shared folder... makes a copy of the newest replica that you can open and change; the replicas stay as they are. Before anyone may open the copy, OSM removes what a shared folder may not hold from the sender's files: device files, and the marks that make a program run with more rights than the person who starts it (set-user-ID and set-group-ID bits, file capabilities).
PCs and servers
Backup > PCs and servers backs up the Windows PCs and Linux servers of your network to this server. Each one runs the program OSM Backup, which backs up its folders on a schedule. Only what changed since the last backup travels, and it is encrypted before it leaves the PC. On Windows, OSM Backup reads the files through a snapshot, so files that are open (a document being edited, a mailbox) are backed up as they were at one moment.
A PC can add versions to its backup, but it can never change or delete one: the server alone decides which versions stay. Ransomware on a PC cannot destroy that PC's backups.
Turning PC backups on
Choose the volume that keeps the backups, then click Turn on. The first time, OSM installs what it needs from its update service. The PCs reach the server on port 5011, from your network only, never from the internet.
The page's Settings button shows the volume and the port. Turn off... there closes the port: the PCs can no longer back up, but they stay in the list with their versions, and back up again when you turn PC backups on.
Adding a PC
- Click Add a PC.... OSM shows a code: it is for one PC, it is valid for 24 hours, and it is shown only this once. The PC must be on the same network as the server.
- On a Windows PC: click Download OSM Backup in the dialog (open the desktop in the PC's browser, or copy the file to the PC). Run it, allow it to make changes, and type the server's address and the code that the dialog shows. Or run the command that the dialog shows in Terminal (Admin), in the folder where the file is.
- On a Linux computer: copy the command for its processor (Intel or AMD, or ARM), and paste it into a terminal as root.
The dialog says when the PC is paired, and the PC appears in the list. Codes that were made and not used yet are listed under the PCs: withdraw one you will not use with its delete button.
Windows warns about OSM Backup. OSM Backup is not signed yet, so Windows says that it protected your PC. Click More info, then Run anyway.
The domain's PCs
When this server is the domain controller, the switch Install OSM Backup on the domain's Windows PCs installs OSM Backup on every Windows PC of the domain, through Group Policy, when the PC starts. Each PC pairs by itself.
- Every account of the domain can read the code that the policy uses. Turn the switch off when you no longer add PCs this way: new PCs no longer get OSM Backup.
- A PC of the domain that you remove comes back at its next start, as long as the policy reaches it.
The list of PCs
Each PC shows its system, its state, its last backup, the room its versions take on this server, and how many versions it has. The state says, for example, Backed up 2 hours ago, Backing up 45 %, Failed with the reason, Last seen 4 days ago (the PC has not been in touch for three days: it is off, or not on the network), Waiting for its first backup, Over its limit, or No longer backs up. The list follows the PCs every 10 seconds.
Click a PC to see more about it, and to:
- Back up now: the PC starts at its next contact, within a minute while it is on.
- Versions...: its versions, to restore from (below).
- Settings...: its name, the folders it backs up and what it leaves out (one per line), when it backs up (every day from an hour you choose, every hour, or by hand), which versions stay, the room it may take on this server, and a limit on its upload speed.
- Check its backup: the server checks the backup now, and reads part of its data.
- Remove...: the PC no longer backs up, and the server refuses it from then on. Keep its versions to restore from later, or delete them for good. OSM Backup stays installed on the PC until you uninstall it there.
A PC backs up once a day as soon as the hour has come; a PC that was off at that hour backs up as soon as it is on again. A backup that fails is tried again 30 minutes later. A PC that has not been in touch for three days is a notification.
By default the latest version stays, then one a day for 7 days, one a week for 4 weeks, one a month for 12 months and one a year for 2 years. The server goes by when each version arrived, never by the PC's clock, and tidies up once a week, at night. A PC over the room it may take has its backups refused until older versions go, or until you raise its limit.
Restoring a PC's files
- Click the PC, then Versions.... The newest version comes first.
- Click Browse... on a version, and tick the files and folders you want. Open a folder by its name; the path at the top goes back.
- Then:
- Send back to the PC: the PC writes them into a new folder named after the date and time, with the folders they were in: under
C:\OSM Restoreon Windows, under/var/lib/osm-backup/restoreon Linux. Nothing on the PC is replaced. The PC starts at its next contact. - Download: one file or folder at a time, to the computer you are using. A folder comes as a ZIP file.
- Send back to the PC: the PC writes them into a new folder named after the date and time, with the folders they were in: under
A PC that no longer backs up cannot receive files, but you can still download from its versions.
The system itself
- The way back after an update: if OSM itself does not start after its update, its version before comes back by itself, and a new kernel is tried once before it is kept. There is no way back by hand. See System.
- Configuration backup: in Settings > Updates and Recovery > Configuration backup, Export saves, and Import... brings back on a new installation, Desktop Access, automatic updates, the server's screen, the groups, the shared folders with their permissions, and whether the firewall is on. It does not bring back the accounts and passwords, the network, the backup tasks or the apps. An import shows what it could not make. It also keeps the record of when the OSM license terms were accepted, and brings it back onto a server that has none (Licenses).
Reset to the defaults
Settings > Updates and Recovery > Reset to the defaults puts OSM's settings back to how a new installation has them, and keeps your data. The page lists exactly what is reset and what stays. In short:
- Reset: the network (DHCP), the web desktop's ports and sign-in settings, the firewall's lists, the ports on the router, the proxy, the password rules, automatic updates, the email settings, and everyone's sign-ins.
- Kept: the volumes, shared folders and every file, snapshots, the apps and virtual machines with their data, the backup, cloud and replication tasks, certificates, and the accounts, unless you choose to reset them too.
The reset menu on the server's own screen (key R) does the same, for when the web desktop cannot be reached. With the accounts too, it makes one new Administrator, administrator, and shows its password once (three words and six digits): sign in with it, then choose your own when the server asks.
A plan that works
- A backup task with everything (shared folders, home folders, settings and accounts, apps' data) to a USB drive or another volume, every night.
- A second task to an off-site destination (an S3 store, or a server at another place), every night or week.
- Immutable snapshots of the shared folders that matter most (Storage), so that ransomware cannot destroy every copy, and two-step sign-in for every Administrator.
- The backup passwords written down away from the server.
- Read the monthly report, and once a year try a full restore onto a spare computer or a virtual machine.