Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

Can't delete snapshots with special characters

cserver

Neophyte
Joined
May 11, 2021
Messages
4
Hello,

Using FreeNAS-11.3-U5

Decided to setup snapshots today that contain [] and spaces in the name. The spaces may not be such an issue...I believe I had those previously but FreeNAS/zfs really does not like those [ ] brackets.

I've deleted thee snapshot tasks and am trying to delete the snapshots but it is failing from the OS using rm and also using zfs destroy.

As an example of one of the snapshots I want to delete:

zfs list -t snapshot
Volume0/backup@Volume0 [Hourly] - 2021-05-10_19-00

rm -rf 'Volume0/backup@Volume0 [Hourly] - 2021-05-10_19-00'
no error but does not get removed

zfs destroy 'Volume0/backup@Volume0 [Hourly] - 2021-05-10_19-00'
could not find any snapshots to destroy; check snapshot names.


I just want to remove the snapshots at this point.
 

sretalla

Wizened Sage
Joined
Jan 1, 2016
Messages
4,336
Try escaping the special characters (and spaces) with backslash... nothing goes in quotes for that...

zfs destroy Volume0/backup@Volume0\ \[Hourly\]\ -\ 2021-05-10_19-00
 

cserver

Neophyte
Joined
May 11, 2021
Messages
4
No luck there but I've been given some other things to try on reddit

root@freenas[/mnt/Volume0/.zfs/snapshot]# zfs destroy Volume0/backup@Volume0\ \[Hourly\]\ -\ 2021-05-10_19-00
could not find any snapshots to destroy; check snapshot names.
 

sretalla

Wizened Sage
Joined
Jan 1, 2016
Messages
4,336
Also no luck from Storage | Snapshots in the GUI?
 

cserver

Neophyte
Joined
May 11, 2021
Messages
4
Correct. FreeNAS let me create the snapshot names but can't delete the snapshots now.
 

sretalla

Wizened Sage
Joined
Jan 1, 2016
Messages
4,336
OK, so can we get at it with rename...?

zfs rename Volume0/backup@Volume0\ \[Hourly\]\ -\ 2021-05-10_19-00 Volume0/backup@RemoveMeNow
 

cserver

Neophyte
Joined
May 11, 2021
Messages
4
No luck with that either. It seems like any zfs command will fail if referencing the spaces or brackets even when escaped, but not sure.

root@freenas[~]# zfs rename Volume0/backup@Volume0\ \[Hourly\]\ -\ 2021-05-10_19-00 Volume0/backup@RemoveMeNow
cannot open 'Volume0/backup@Volume0 [Hourly] - 2021-05-10_19-00': invalid character '[' in name

I'm OK deleting all snapshots. Going to also look into deleting by ID but I can't get the snapshot ID using zfs if it references the specific snapshot.
 

sretalla

Wizened Sage
Joined
Jan 1, 2016
Messages
4,336
So for sure you're in difficult waters there... based on this:

and supplementally this:

You can't have square brackets, so I guess all the commands won't let you touch things that have them... leading to the question "how did it get created in the first place like that?"

I'm OK deleting all snapshots. Going to also look into deleting by ID but I can't get the snapshot ID using zfs if it references the specific snapshot.
Where you may be in luck is if that's not the oldest snapshot and you can make a newer one, then using % between the snapshot names of oldest and newest (or older and newer if that's an option) to get all the snapshots in-between:
zfs destroy Volume0/backup@olderSnap%newerSnap
 
Top