Open Mac1ej opened 6 years ago
I will be grateful for the information from the developers, whether the situation described above is a normal behavior resulting from the current state of application development, or if I am doing something wrong.
As a temporary workaround I made two shell scripts. Runing the first one on server startup (/etc/rc.local) and at the end of snapper's cron job (/etc/cron.hourly/snapper) makes "previous versions" working for samba clients (Shadow Copy). The second script is only just in case. I have tested that snapper deletes snapshots whithout problems even if they are mounted, so I assume that cleanup job (/etc/cron.daily/snapper) can be left without any modifications.
snapsmount
#!/bin/sh
#
# --- snapsmount ---
# this script mounts all snapshots managed by snapper for
# all mounted volumes in given directory (define BASEDIR),
# it runs silently by default and verbose mode can be
# switched on by "-v" parameter
#
# written on 2018-03-14 by Maciej Aneszko (mac@warpol.net)
#
# this is free software under the terms of the GNU General
# Public License Version 2
BASEDIR=/thin
unset VERBOSE
if [ "$1" = "-v" ]; then VERBOSE=1; fi
for NAMEPATH in $BASEDIR/*; do
NAME=$(snapper list-configs | grep " $NAMEPATH *$" | cut -f 1 -d "|")
if [ $NAME ]; then
if [ $VERBOSE ]; then echo "CONFIG: $NAME"; fi
for NUMPATH in $NAMEPATH/.snapshots/*; do
if [ $VERBOSE ]; then echo -n " checking $NUMPATH... "; fi
if [ -d "$NUMPATH" ] && [ -x "$NUMPATH" ]; then
if [ $VERBOSE ]; then echo "directory readable"; fi
if grep -q " $NUMPATH/snapshot " /proc/mounts; then
if [ $VERBOSE ]; then echo " already MOUNTED"; fi
else
NUM=$(basename "$NUMPATH")
if [ $VERBOSE ]; then echo " mounting snapshot $NUM for $NAME"; fi
snapper -c $NAME mount $NUM
fi
else
if [ $VERBOSE ]; then echo "UNREADABLE!"; fi
fi
done
else
if [ $VERBOSE ]; then echo "no CONFIG for $NAMEPATH"; fi
fi
done
snapsumount
#!/bin/sh
#
# --- snapsumount ---
# this script umounts all snapshots managed by snapper for
# all mounted volumes in given directory (define BASEDIR),
# it runs silently by default and verbose mode can be
# switched on by "-v" parameter
#
# written on 2018-03-14 by Maciej Aneszko (mac@warpol.net)
#
# this is free software under the terms of the GNU General
# Public License Version 2
BASEDIR=/thin
unset VERBOSE
if [ "$1" = "-v" ]; then VERBOSE=1; fi
for NAMEPATH in $BASEDIR/*; do
NAME=$(snapper list-configs | grep " $NAMEPATH *$" | cut -f 1 -d "|")
if [ $NAME ]; then
if [ $VERBOSE ]; then echo "CONFIG: $NAME"; fi
for NUMPATH in $NAMEPATH/.snapshots/*; do
if [ $VERBOSE ]; then echo -n " checking $NUMPATH... "; fi
if [ -d "$NUMPATH" ] && [ -x "$NUMPATH" ]; then
if [ $VERBOSE ]; then echo "directory readable"; fi
if grep -q " $NUMPATH/snapshot " /proc/mounts; then
NUM=$(basename "$NUMPATH")
if [ $VERBOSE ]; then echo " umounting snapshot $NUM from $NAME"; fi
snapper -c $NAME umount $NUM
else
if [ $VERBOSE ]; then echo " not MOUNTED"; fi
fi
else
if [ $VERBOSE ]; then echo "UNREADABLE!"; fi
fi
done
else
if [ $VERBOSE ]; then echo "no CONFIG for $NAMEPATH"; fi
fi
done
Of course the better solution would be an option in snapper's config that cause mounting the created snapshots immediately and mounting them on boot (e.g. ALWAYS_MOUNT). But until this feature is implemented the above scripts can be useful to someone who is in situation similar to mine.
Thanks for the report. The Samba vfs_snapper currently only works with btrfs backed shares. I'll raise a bug to track this on bugzilla.samba.org, as this restriction should at least be documented in the vfs_snapper(8) man page. Regarding a proper implementation, on the Samba side it should be possible to have vfs_snapper mount snapshots on demand in the SMB enumerate-snapshots codepath, but I'd much prefer an upstream Snapper config option that performed auto-mounting.
Automatically mounting snapshots might be possible using autofs. Mounting of all snapshots at startup might also be possible but so far snapper is not run during the boot process.
Anyway, since SUSE if fixated on btrfs these feature will likely have to be provided by someone else.
I also have issues with vfs_snapper and a btrfs backed share. Debian-12.5
flags btrfs,lvm,no-ext4,xattrs,rollback,btrfs-quota,no-selinux
I might open a new issue ...
I also have issues with vfs_snapper and a btrfs backed share. Debian-12.5 ... I might open a new issue ...
Please do. If you think the bug is Samba / vfs_snapper related then feel free to open a ticket at bugzilla.samba.org
https://github.com/openSUSE/snapper/issues/917 ... I think at first the ACL-topic has to be fixed. thanks
Hi, I have Ubuntu 16.04.3 LTS (kernel 4.4.0-101-generic) with samba 4.9.0pre1-GIT-ffcc367 (installed/compiled from "git clone", because Ubuntu's version does not contain snapper.so module). Snapper is installed (according to instruction at snapper.io) from deb http://download.opensuse.org/repositories/filesystems:/snapper/xUbuntu_16.04/ (snapper 0.5.4 - flags btrfs,lvm,no-ext4,xattrs,no-rollback,no-btrfs-quota,no-selinux).
I have configured LVM Thin Provisioning pool and volumes with ext4 filesystem. For each volume I have created snapper config:
sudo snapper -c name create-config -f "lvm(ext4)" /thin/name
Then I set the permissions:
sudo snapper -c name set-config ALLOW_USERS=username
sudo snapper -c name set-config SYNC_ACL=yes
In smb.conf I have defined shares:
[Name]
hide files = /lost+found/
path = /thin/name
valid users = username
vfs objects = snapper
write list = username
Everything seems to work as it should except of Shadow Copy - when trying to see "previous versions" from Windows client, then: 1) trying at share it shows all snapshots but they cannot be opened or restored (access denied), 2) trying at file/folder inside a share it does not show any snapshot.
I can enter (as Windows client) /thin/name/.snapshots and see appropriate numbers, entering this numbers I see snapshot folder and info.xml file. For both access is denied (owner is root with no permission for others). So snapper has set appropriate ACL permissions as I previously configured, but snapshot is not visible at given snapshot folder.
After giving a command:
sudo snapper -c name mount number
snapshot with given number is mounted and then it is accessible for Windows client in "snapshot" folder and in "previous versions" (Shadow Copy).I think that snapper should mount/umount these snapshots on demand but it does not do it. Or even if the snapshot was mounted for the whole its timelife it would work properly.
Is there any solution to mount these snapshots on demand or permanently? Of course then the snapper should umount them when trying to delete (cleanup).
I think this is a bug or I have missconfigured something, because in this case users cannot access snapshots at all (with or without using shadow copy), assuming they have no shell access (cannot use snapper command).