All checks were successful
buildbot/nix-build .#checks.aarch64-darwin.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.x86_64-linux.check-for-breakpoints Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-ts-api Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-iso-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.package-default Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-deb Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-fakeroot Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-git Build done.
buildbot/nix-build .#checks.x86_64-linux.package-module-docs Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-flash-installer Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-iso-installer Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-flash-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-cli-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-cli Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-archlinux Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-e2fsprogs Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-rpm Build done.
buildbot/nix-build .#checks.aarch64-darwin.nixos-test-backup Build done.
buildbot/nix-build .#checks.x86_64-linux."clan-dep-python3.11-qemu" Build done.
buildbot/nix-build .#checks.aarch64-linux.nixos-test-backup Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-nix Build done.
buildbot/nix-build .#checks.x86_64-linux.renderClanOptions Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-openssh Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-webview-ui Build done.
buildbot/nix-build .#checks.x86_64-linux."clan-dep-python3.11-mypy" Build done.
buildbot/nix-build .#checks.x86_64-linux.deltachat Build done.
buildbot/nix-build .#checks.x86_64-linux.borgbackup Build done.
buildbot/nix-build .#checks.x86_64-linux.matrix-synapse Build done.
buildbot/nix-build .#checks.x86_64-linux.package-editor Build done.
buildbot/nix-build .#checks.x86_64-linux.package-merge-after-ci Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zt-tcp-relay Build done.
buildbot/nix-build .#checks.x86_64-linux.postgresql Build done.
buildbot/nix-build .#checks.x86_64-linux.package-function-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.secrets Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-rsync Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-sops Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-bash Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-test-backup Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-sshpass Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-zbar Build done.
buildbot/nix-build .#checks.x86_64-linux.package-gui-installer-apk Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-age Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-dep-tor Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-app-no-breakpoints Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-default Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-clan-cli Build done.
buildbot/nix-build .#checks.x86_64-linux.container Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-jsonschema-example-valid Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-app-pytest Build done.
buildbot/nix-build .#checks.x86_64-linux.lib-jsonschema-nix-unit-tests Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-test_install_machine Build done.
buildbot/nix-build .#checks.x86_64-linux.package-deploy-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.module-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.package-impure-checks Build done.
buildbot/nix-build .#checks.x86_64-linux.treefmt Build done.
buildbot/nix-build .#checks.x86_64-linux.package-moonlight-sunshine-accept Build done.
buildbot/nix-build .#checks.x86_64-linux.package-pending-reviews Build done.
buildbot/nix-build .#checks.x86_64-linux.package-tea-create-pr Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zerotier-members Build done.
buildbot/nix-build .#checks.x86_64-linux.package-zerotierone Build done.
buildbot/nix-build .#checks.x86_64-linux.package-docs Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-pytest-without-core Build done.
buildbot/nix-build .#checks.x86_64-linux.package-webview-ui Build done.
buildbot/nix-build .#checks.x86_64-linux.package-clan-app Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-flash-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.nixos-iso-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.template-minimal Build done.
buildbot/nix-build .#checks.x86_64-linux.package-module-schema Build done.
buildbot/nix-build .#checks.x86_64-linux.wayland-proxy-virtwl Build done.
buildbot/nix-build .#checks.x86_64-linux.zt-tcp-relay Build done.
buildbot/nix-build .#checks.x86_64-linux.package-iso-installer Build done.
buildbot/nix-build .#checks.x86_64-linux.syncthing Build done.
buildbot/nix-build .#checks.x86_64-linux.devShell-clan-app Build done.
buildbot/nix-build .#checks.x86_64-linux.clan-pytest-with-core Build done.
checks / checks-impure (pull_request) Successful in 2m10s
buildbot/nix-build .#checks.x86_64-linux.package-gui-install-test-ubuntu-22-04 Build done.
buildbot/nix-build .#checks.x86_64-linux.test-backups Build done.
buildbot/nix-build .#checks.x86_64-linux.flash Build done.
buildbot/nix-build .#checks.x86_64-linux.test-installation Build done.
buildbot/nix-eval Build done.
150 lines
3.9 KiB
Markdown
150 lines
3.9 KiB
Markdown
# Backups
|
|
|
|
## Introduction to Backups
|
|
|
|
When you're managing your own services, creating regular backups is crucial to ensure your data's safety.
|
|
This guide introduces you to Clan's built-in backup functionalities.
|
|
Clan supports backing up your data to both local storage devices (like USB drives) and remote servers, using well-known tools like borgbackup and rsnapshot.
|
|
We might add more options in the future, but for now, let's dive into how you can secure your data.
|
|
|
|
## Backing Up Locally with Localbackup
|
|
|
|
### What is Localbackup?
|
|
|
|
Localbackup lets you backup your data onto physical storage devices connected to your computer,
|
|
such as USB hard drives or network-attached storage. It uses a tool called rsnapshot for this purpose.
|
|
|
|
### Setting Up Localbackup
|
|
|
|
1. **Identify Your Backup Device:**
|
|
|
|
First, figure out which device you'll use for backups. You can see all connected devices by running this command in your terminal:
|
|
|
|
```bash
|
|
lsblk --output NAME,PTUUID,FSTYPE,SIZE,MOUNTPOINT
|
|
```
|
|
|
|
Look for the device you intend to use for backups and note its details.
|
|
|
|
2. **Configure Your Backup Device:**
|
|
|
|
Once you've identified your device, you'll need to add it to your configuration.
|
|
Here's an example NixOS configuration for a device located at `/dev/sda2` with an `ext4` filesystem:
|
|
|
|
```nix
|
|
{
|
|
fileSystems."/mnt/hdd" = {
|
|
device = "/dev/sda2";
|
|
fsType = "ext4";
|
|
options = [ "defaults" "noauto" ];
|
|
};
|
|
}
|
|
```
|
|
|
|
Replace `/dev/sda2` with your device and `/mnt/hdd` with your preferred mount point.
|
|
|
|
3. **Set Backup Targets:** Next, define where on your device you'd like the backups to be stored:
|
|
|
|
```nix
|
|
{
|
|
clan.localbackup.targets.hdd = {
|
|
directory = "/mnt/hdd/backup";
|
|
mountpoint = "/mnt/hdd";
|
|
};
|
|
}
|
|
```
|
|
|
|
Change `/mnt/hdd` to the actual mount point you're using.
|
|
|
|
4. **Create Backups:** To create a backup, run:
|
|
|
|
```bash
|
|
clan backups create mymachine
|
|
```
|
|
|
|
This command saves snapshots of your data onto the backup device.
|
|
|
|
5. **Listing Backups:** To see available backups, run:
|
|
|
|
```bash
|
|
clan backups list mymachine
|
|
```
|
|
|
|
## Remote Backups with Borgbackup
|
|
|
|
### Overview of Borgbackup
|
|
|
|
Borgbackup splits the backup process into two parts: a backup client that sends data to a backup server.
|
|
The server stores the backups.
|
|
|
|
### Setting Up the Borgbackup Client
|
|
|
|
1. **Specify Backup Server:**
|
|
|
|
Start by indicating where your backup data should be sent. Replace `hostname` with your server's address:
|
|
|
|
```nix
|
|
{
|
|
clan.borgbackup.destinations = {
|
|
myhostname = {
|
|
repo = "borg@backuphost:/var/lib/borgbackup/myhostname";
|
|
};
|
|
};
|
|
}
|
|
```
|
|
|
|
2. **Select Folders to Backup:**
|
|
|
|
Decide which folders you want to back up. For example, to backup your home and root directories:
|
|
|
|
```nix
|
|
{ clan.core.state.userdata.folders = [ "/home" "/root" ]; }
|
|
```
|
|
|
|
3. **Generate Backup Credentials:**
|
|
|
|
Run `clan facts generate <yourmachine>` to prepare your machine for backup, creating necessary SSH keys and credentials.
|
|
|
|
### Setting Up the Borgbackup Server
|
|
|
|
1. **Configure Backup Repository:**
|
|
|
|
On the server where backups will be stored, enable the SSH daemon and set up a repository for each client:
|
|
|
|
```nix
|
|
{
|
|
services.borgbackup.repos.myhostname = {
|
|
path = "/var/lib/borgbackup/myhostname";
|
|
authorizedKeys = [
|
|
(builtins.readFile (config.clan.core.clanDir + "/machines/myhostname/facts/borgbackup.ssh.pub"))
|
|
];
|
|
};
|
|
}
|
|
```
|
|
|
|
Ensure the path to the public key is correct.
|
|
|
|
2. **Update Your Systems:** Apply your changes by running `clan machines update` to both the server and your client
|
|
|
|
### Managing Backups
|
|
|
|
- **Scheduled Backups:**
|
|
|
|
Backups are automatically performed nightly. To check the next scheduled backup, use:
|
|
|
|
```bash
|
|
systemctl list-timers | grep -E 'NEXT|borg'
|
|
```
|
|
|
|
- **Listing Backups:** To see available backups, run:
|
|
|
|
```bash
|
|
clan backups list mymachine
|
|
```
|
|
|
|
- **Manual Backups:** You can also initiate a backup manually:
|
|
|
|
```bash
|
|
clan backups create mymachine
|
|
```
|