08:18:51 Hi. I am trying to create and delete ZFS snapshots using the crontab, creation works ok, but I am facing issues with the deleting part. 08:19:00 The crontab entry looks like this: 08:19:11 SHELL=/usr/bin/zsh 08:20:15 10 21 * * * /usr/sbin/zfs destroy -r tank@`TZ=$TZ+167 date +'%Y-%m-%d'` 2>> /var/log/zfs.destroy 08:20:27 However I am getting the following error: 08:20:53 zsh:1: unmatched ` 08:22:18 If you are wondering the +167 is the maximum offset value TZ accepts, with this I attempt to delete snapshots older than 7 days, or so. 08:23:18 the command works just fine in root ZSH shell, but it fails in crontab, so there must be some differences, but I don't know, how to find it. 08:25:06 I have already tried to change the command to : tank@$(TZ=$TZ+167 date +'%Y-%m-%d') but it didn't help 08:25:29 Please let me know if oyu have any better solution for this. 08:59:06 your could move the code into a shell script file with #!/usr/bin/zsh on the first line and led crontab call that file 09:07:26 my apporach to deleting autmatic snapshots is having a dedidacted constant part in the name like "autobackup_" and the date in seconds. Then a zfs list -r -t snapshot -o name | grep autobackup_ and then not delete the last n-number snapshots 09:08:16 (or egrep "@autobackup_1[0-9]*$" ) 09:12:21 tomww: Thanks for the hint, I'll test it and will also think about your approach. 09:12:24 Thanks again. 09:23:26 you’re welcome 09:57:27 I'd liek to use a USB drive for cold backup. I'd liek to have a ZFS pool on it, so i can send snapshots there. Am I supposed to create a partition and create Zpool on that partition, or should I use the raw device itself for the pool? 10:54:22 tomww: what do you think about this aproach: 10:54:24 /usr/sbin/zfs list -d 1 -H -o name -t snapshot | grep "tank@" | tail -n +7 | xargs /usr/sbin/zfs destroy -r 10:55:20 -d 1 means it lists non-recursively (so it emmits only the top level dataset names 10:55:39 -H means it ommits the output header (this is not really needed) 10:55:56 -o will instruct zfs to list only the name property 10:56:22 tail -n +7 means it ommits the first 7 items 10:56:41 So it deletes all snapshots except the 7 most recent ones 11:43:02 I try to never stript a "destroy -r". instead I try to identify every single zfs filesystem and loop over that one to find all snapshots in there. 11:45:52 and for the first run I prefix the destroy command with "echo" to only see the command it _would_ run. 11:50:34 tomw, I agree. 11:50:44 I have modified my script like this: 11:51:08 /usr/sbin/zfs list -d 1 -o name -t snapshot | grep "tank@autobackup" | tail -n +7 | xargs /usr/sbin/zfs destroy -r 11:51:47 note: I'm only reading occationally here, so scripting support is very limited on my side 11:51:49 included autobackup in the grep, so it will list only applicable snapshots from tank and will keep the 7 most recent version 11:52:32 I still do not use a "-r" in destroy. think of a clone dependent on a snapshot. I might be killed the clone. 11:55:00 I haven't tried zfs cloning feature yet. 11:55:13 I haven't used many of the zfs features yet. 11:55:20 But thanks for the hint. 15:16:07 if a clone is dependent on a snapshot -r is not enough to delete it. You need -R in that case. 16:47:46 I am wondering, why is there . and .. in my / 20:16:21 . is everywhere 20:20:09 . and .. show up in my omnios and linux systems in /