-
First of all, thanks for putting this package together. I have been using zfs on my system for a while, but I am not yet comfortable with all the features of this tool. In particular, I am unsure about the correct way of mounting a backup dataset to retrieve a file. I am using your tool. I have followed the quickstart guide to backup to a local storage, that is: > sudo zfs set autobackup:local=true rpool
> sudo zpool import -R /mnt/backup backups
> sudo zfs-autobackup -v local backups/autobackup So far so good. The backup is resting on the local storage and I can see it by listing all the datasets with Now, I would like to mount the backup to retrieve a file. Initially, I tried the following: > zpool import -R /mnt/backup backups
> zfs mount -laO However, when I tried to mount I got the following error: cannot mount '/mnt/bakup/rpool/USERDATA/user_3ab41a': failed to create mountpoint: Read-only file system To circumvent this problem, I modified the > sudo inherit -rS readonly backup I exported and imported the pool again. Finally I managed to mount. But I felt this was unsafe. So, I went back and turned the > sudo zfs set readonly=on backup Which somehow set cannot mount '/mnt/mameara/usr/local': failed to create mountpoint: Read-only file system Are these steps correct? Why am I still not able to mount the Will FInally, when mounting ZFS asks for the password for every single dataset. Previously, when I was backing up manually. It somehow only requested the password at the top-level dataset. Thanks for your help. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
this is a common problem: readonly prevents linux from creating the mountpoint. there are two options: make sure the mountpoint exists (maybe by creating the directory on the source server) or change the mountpoint property. zfs-autobackup wont reset the properties. edwin |
Beta Was this translation helpful? Give feedback.
-
I am not able to properly answer all of the questions, but for a few; When working with backups (other than transferring them in full) I always recommend working with clones. For example:
and then work on the For the encryption password related one, I believe this depends on how you backup the datasets (decrypt & re-encrypt, or transfer as-is, is the encryption root backed up as well, ..) and what ends up being their encryption root on the backup target. You can check this with In my setup I use decrypt & re-encrypt (in order to be able to change the dataset compression from lz4 to gzip to save space since performance is not a concern on the backups) so I end up with the same encryptionroot, and thus I only need to provide the password for the root dataset, so I'm not able to help here further since I'm not seeing this, but hopefully this provided some pointers on what to search for. For reference, the command I use in my nightly script is:
where $HOST is what's being backed up, $STORAGE_HOST is the host that holds the backups, and $DATASET is the dataset to backup to. This script runs on a dedicated, hardened "backupper machine" that only connects to hosts that needs backing up and hosts that hold the actual backups. I also clear the refreservation and quota since I don't want those to limit the amount of backups I can hold, I use them on the source hosts to prevent a single service (or other dataset user) from filling up the entire pool, causing everything else to break as well. |
Beta Was this translation helpful? Give feedback.
-
Many thanks for your help! I managed to put together a script to combine zfs-autobackup with borg to perform additional cloud backups. Unfortunately, ZFS providers are still quite pricey, so I will use borg for that. The script I put together is below. If you have any additional suggestions. #!/bin/sh
# Borgmatic hook: ZFS Autobackup
#
# usage: borgmatic_hook_zfs_autobackup {clone,destroy} [zfs_mountpoint] [zfs_autobackup_label] [borg_mountpoint]
#
# The script defines two borgmatic hooks to be used as a `before_actions` and `after_actions` hook.
#
# Before borgmatic actions, the hook takes a ZFS snapshot using `zfs-autobackup`. Then
# creates a ZFS clone and mounts the snapshot to prepare it for borg backup.
#
# After borgmatic actions, the hook destroys the ZFS clone.
#
# See:
# https://github.com/scotte/borgsnap
# https://github.com/mikroskeem/zorg
set -eu
usage() {
echo "usage: borgmatic_hook_zfs_autobackup {clone,destroy} [zfs_mountpoint] [zfs_autobackup_label] [borg_mountpoint]"
exit 1
}
destroy() {
zfs destroy "rpool/borg"
}
assert_no_borg_clone() {
set +e
zfs list -t filesystem rpool/borg >/dev/null 2>&1
if [ $? -eq 0 ]; then
if [ $# -ne 0 ]; then
echo "rpool/borg exists, aborting."
# soft fail
exit 75
else
destroy
assert_no_borg_clone 'no-retry'
fi
fi
set -e
}
assert_borg_clone() {
set +e
zfs list -t filesystem rpool/borg >/dev/null 2>&1
if [ $? -ne 0 ]; then
exit 0
fi
set -e
}
snapshot() {
zfs-autobackup --keep-source 2,1d1w,1w1m,1m6m --keep-target 2,1d1w,1w1m,1m6m ${1}
}
findlast() {
zfs list -d 1 -s name -t snap -o name "${1}" | grep "@${2}-" | tail -1
}
clone() {
mkdir -p ${1}
zfs clone -o mountpoint=${1} -o readonly=on -o autobackup:${2}=false ${3} rpool/borg
echo "rpool/borg"
}
if [ $# -ne 4 ]; then usage; fi
hook=$1
zfs_mountpoint=$2
zfs_autobackup_label=$3
borg_mountpoint=$4
case ${hook} in
create)
assert_no_borg_clone
snapshot ${zfs_autobackup_label}
last_snapshot=$(findlast ${zfs_mountpoint} ${zfs_autobackup_label})
echo "Found snapshot: '${last_snapshot}'."
clone ${borg_mountpoint} ${zfs_autobackup_label} ${last_snapshot}
;;
destroy)
assert_borg_clone
destroy
;;
*)
usage
exit 1
;;
esac |
Beta Was this translation helpful? Give feedback.
-
Since this is a common problem i've created a wiki page: https://github.com/psy0rz/zfs_autobackup/wiki/Mounting |
Beta Was this translation helpful? Give feedback.
I am not able to properly answer all of the questions, but for a few;
When working with backups (other than transferring them in full) I always recommend working with clones. For example:
and then work on the
backups/recovery-operation-1
dataset rather than thebackups/something/someset
. Change its properties, mount it, do modifications, do whatever you want without risking damaging your actual backups (andzfs destroy
the clone once you no longer need it)For the encryption password related one, I believe this depends on how you backup the datasets (decrypt & re-encrypt, or transfer as-is, is the enc…