teejee2008 / timeshift

System restore tool for Linux. Creates filesystem snapshots using rsync+hardlinks, or BTRFS snapshots. Supports scheduled snapshots, multiple backup levels, and exclude filters. Snapshots can be restored while system is running or from Live CD/USB.
GNU Lesser General Public License v3.0
4.69k stars 282 forks source link

Unable to delete btrfs snapshots #803

Open SuspiciousSalmon opened 3 years ago

SuspiciousSalmon commented 3 years ago

Hello, I am unable to delete btrfs snapshots. When I try to remove them I get these errors.

------------------------------------------------------------------------------
Removing snapshot: 2021-09-24_18-16-10
Deleting subvolume: @ (Id:350)
E: ERROR: Not a Btrfs subvolume: Invalid argument

E: Failed to delete snapshot nested subvolume: '/run/timeshift/backup/timeshift-btrfs/snapshots/2021-09-24_18-16-10/@'
E: Failed to remove snapshot: 2021-09-24_18-16-10
------------------------------------------------------------------------------

However I am able to delete the manually by doing sudo btrfs subvol remove delete /run/timshift/backup/timeshift-btrfs/snapshots/2021-09-24_18-16-10/@ and then removing it from the gui.

Outputs that might be useful Output of sudo btrfs subvol list /

ID 257 gen 24064 top level 5 path @home
ID 349 gen 24064 top level 5 path @
ID 350 gen 24032 top level 5 path timeshift-btrfs/snapshots/2021-09-24_18-16-10/@

Edit:

[18:16:19] Main: check_dependencies()
[18:16:19] Main: add_default_exclude_entries()
[18:16:19] Main: add_default_exclude_entries(): exit
[18:16:19] update_partitions()
[18:16:19] Device: get_disk_space_using_df(): 4
[18:16:19] Device: get_mounted_filesystems_using_mtab(): 2
[18:16:19] Device: get_filesystems(): 7
[18:16:19] partition list updated
[18:16:19] detect_system_devices()
[18:16:19] Searching subvolume for system at path: /
[18:16:19] Found subvolume: @, on device: /dev/dm-0
[18:16:19] Found subvolume: @home, on device: /dev/dm-0
[18:16:19] Users: root #########
[18:16:19] Encrypted home users: 
[18:16:19] Encrypted home dirs:

[18:16:19] Encrypted private dirs:

[18:16:19] Main: load_app_config()
[18:16:19] IconManager: init()
[18:16:19] bin_path: /usr/bin/timeshift
[18:16:19] found images directory: /usr/share/timeshift/images
[18:16:19] Main(): ok
[18:16:19] AppConsole: parse_arguments()
[18:16:19] Main: initialize_repo()
[18:16:19] backup_uuid=801a6b5f-#######################
[18:16:19] backup_parent_uuid=f101babf-#######################
[18:16:19] Setting snapshot device from config file
[18:16:19] repo: creating from uuid
[18:16:19] SnapshotRepo: from_uuid(): BTRFS
[18:16:19] uuid=801a6b5f-#######################
[18:16:19] SnapshotRepo: init_from_device()
[18:16:19] 
[18:16:19] SnapshotRepo: unlock_and_mount_devices()
[18:16:19] device=/dev/dm-0
[18:16:19] SnapshotRepo: unlock_and_mount_device()
[18:16:19] device=/dev/dm-0
[18:16:19] Device: get_mounted_filesystems_using_mtab(): 2
[18:16:19] ------------------
[18:16:19] arg=801a6b5f-#######################, device=/dev/dm-0
[18:16:19] /run/timeshift/backup
[18:16:19] /home
[18:16:19] /
[18:16:19] ------------------
[18:16:19] 
/dev/dm-0 is mounted at: /run/timeshift/backup, options: rw,relatime,ssd,space_cache,subvolid=5,subvol=/

[18:16:19] Searching subvolume for system at path: /run/timeshift/backup/@
[18:16:19] Found subvolume: @, on device: /dev/dm-0
[18:16:19] Found subvolume: @home, on device: /dev/dm-0
[18:16:19] SnapshotRepo: load_snapshots()
[18:16:19] Querying subvolume info...
[18:16:19] query_subvolume_id():@
[18:16:19] btrfs subvolume list '/run/timeshift/backup'
[18:16:19] query_subvolume_quota():@
[18:16:19] btrfs qgroup show --raw '/run/timeshift/backup'
[18:16:20] Query completed
[18:16:20] loading snapshots from '/run/timeshift/backup/timeshift-btrfs/snapshots': 1 found
[18:16:20] SnapshotRepo: unlock_and_mount_device(): exit
[18:16:20] Selected snapshot device: /dev/dm-0
[18:16:20] Free space: 36.1 GB
[18:16:20] SnapshotRepo: check_status()
[18:16:20] SnapshotRepo: available()
[18:16:20] SnapshotRepo: has_btrfs_system()
[18:16:20] root_path=/run/timeshift/backup/@
[18:16:20] btrfs_mode=true
[18:16:20] is_available: ok
[18:16:20] SnapshotRepo: has_snapshots()
[18:16:20] SnapshotRepo: has_space()
[18:16:20] Device: get_disk_space_using_df(): 1
[18:16:20] SnapshotRepo: check_status(): exit
[18:16:20] SnapshotRepo: init_from_device(): exit
[18:16:20] SnapshotRepo: from_uuid(): exit
[18:16:20] Main: initialize_repo(): exit
[18:16:20] AppConsole: start_application()
[18:16:20] AppConsole: select_snapshot()
[18:16:20] SnapshotRepo: has_snapshots()
[18:16:20] 
[18:16:20] Select snapshot:

[18:16:20] 
[18:16:22] 
[18:16:22] ------------------------------------------------------------------------------
[18:16:22] Removing snapshot: 2021-09-24_18-16-10
[18:16:22] Deleting subvolume: @ (Id:350)
[18:16:22] Deleting nested subvolume in snapshot
[18:16:22] btrfs subvolume delete --commit-after '/run/timeshift/backup/timeshift-btrfs/snapshots/2021-09-24_18-16-10/@/@'
[18:16:22] E: ERROR: Not a Btrfs subvolume: Invalid argument

[18:16:22] E: Failed to delete snapshot nested subvolume: '/run/timeshift/backup/timeshift-btrfs/snapshots/2021-09-24_18-16-10/@'
[18:16:22] E: Failed to remove snapshot: 2021-09-24_18-16-10
[18:16:22] ------------------------------------------------------------------------------
[18:16:22] exit_app()
[18:16:22] crontab -l
[18:16:22] Failed to read cron tab
[18:16:22] crontab -l
[18:16:22] Failed to read cron tab
[18:16:22] Cron task exists: /etc/cron.d/timeshift-hourly
[18:16:22] unmount_target_device()
[18:16:22] clean_logs()
[18:16:22] rm -rf '/tmp/O0BNl2Dd'

System:

Note: I am using btrfs on luks encryption.

Any help is appriciated, thank you.

ShrirajHegde commented 2 years ago

Looks like you have nested subvolumes. Delete the inner subvolume with btrfs subvolume delete path-to-inner-subvol and try deleting the snapshot again.