koverstreet / bcachefs-tools

http://bcachefs.org
GNU General Public License v2.0
124 stars 91 forks source link

bcachefs subvolume snapshot doesn't seem to run in anacron #186

Open jpsollie opened 11 months ago

jpsollie commented 11 months ago

The cause of it may very well be something else, but I have no clue, so maybe ... maybe someone has an idea what to verify. I have a backup script for my bcachefs volumes. The bcachefs volume is getting backed up onto a btrfs filesystem (thus omitting SPOF: other device, other FS). Both volumes are being snapshotted before the actual sync. Here's the code:

 cat /etc/cron.monthly/backups.sh 
#!/bin/bash
# backup important data to usbbackup (multimedia) and satabackup (securestorage)
# backups are done using rsync, no
declare -a pids;

ismounted=$(grep usbbackup /proc/mounts);
if [[ $ismounted == "" ]]; then
        mount /mnt/usbbackup;
fi;
if [[ -f "/var/log/mmbackup.log" ]]; then 
        mv "/var/log/mmbackup.log" "/var/log/mmbackup-before-$(date +%y%m%d%H).log";
fi;
btrfs subvolume snapshot -r /mnt/usbbackup "/mnt/usbbackup/snapshot-$(date +'%d%m%y')"
cd /data/multimedia
bcachefs subvolume snapshot -r . .snapshots/auto-$(date +'%d%m%y')
nice rsync -a --delete /data/multimedia/ /mnt/usbbackup/live/ --exclude=.snapshots --log-file=/var/log/mmbackup.log > /dev/null 2>&1 &
pids+=("$!");

ismounted=$(grep satabackup /proc/mounts)
if [[ $ismounted == "" ]]; then
        mount /mnt/satabackup;
fi;
if [[ -f "/var/log/secstorbackup.log" ]]; then 
        mv "/var/log/secstorbackup.log" "/var/log/secstorbackup-before-$(date +%y%m%d%H).log";
fi;
btrfs subvolume snapshot -r /mnt/satabackup "/mnt/satabackup/snapshot-$(date +'%d%m%y')";
cd /data/securestorage
bcachefs subvolume snapshot -r . .snapshots/auto-$(date +'%d%m%y')
nice rsync -a --delete /data/securestorage/ /mnt/satabackup/live/ --exclude=.snapshots --log-file=/var/log/secstorbackup.log > /dev/null 2>&1 &
pids+=("$!");

wait ${pids[0]};
wait ${pids[1]};

umount /mnt/usbbackup;
umount /mnt/satabackup;

linuxserver /home/janpieter # ls /mnt/satabackup
live snapshot-080922  snapshot-100323  snapshot-110323  snapshot-120123  snapshot-121122  snapshot-140323 snapshot-061222  snapshot-090223  snapshot-101022  snapshot-110923  snapshot-120323  snapshot-121222  snapshot-201123
snapshot-080823  snapshot-090323  snapshot-101123  snapshot-111023  snapshot-120823  snapshot-130323  snapshot-300723
linuxserver /home/janpieter # ls /data/securestorage/.snapshots/
auto-080823

linuxserver /home/janpieter # ls /var/log/secstorbackup-before-*
/var/log/secstorbackup-before-23051303.log  /var/log/secstorbackup-before-23071203.log  /var/log/secstorbackup-before-23081203.log  /var/log/secstorbackup-before-23101103.log  /var/log/secstorbackup-before-23112000.log
/var/log/secstorbackup-before-23061203.log  /var/log/secstorbackup-before-23080821.log  /var/log/secstorbackup-before-23091103.log  /var/log/secstorbackup-before-23111004.log  /var/log/secstorbackup-before-23112009.log

So, the question is pretty easy: why does it create a btrfs snapshot, and perform the rsync, but not the bcachefs snapshot?

if I run the script manually (as root), everything is ok:

sh /etc/cron.monthly/backups.sh 
Create a readonly snapshot of '/mnt/usbbackup' in '/mnt/usbbackup/snapshot-241123'
Create a readonly snapshot of '/mnt/satabackup' in '/mnt/satabackup/snapshot-241123'
linuxserver /home/janpieter # ls /data/securestorage/.snapshots/
auto-080823  auto-241123

any ideas? I got no clue at all