linuxmint / 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.
1.53k stars 75 forks source link

timeshift-gtk reports E: Failed to remove directory when the program exit #274

Open ronohara opened 5 months ago

ronohara commented 5 months ago

Describe the bug timeshift-gtk reports E: Failed to remove directory when the program exit

To Reproduce Very difficult to reproduce. Triggered by some other part of the application leaving the 'run directory' busy. Once that has occurred, simply starting the application and then exiting will show the message - until the next reboot. See the rest of this bug for ramifications.

Expected behavior Did not expect an error message - and the message could be more informative.

Screenshots If applicable, add screenshots to help explain your problem.

System:

MORE:

If you run this from the command line : sudo timeshit-gtk sometimes you get an error message when you exit the app.

E: Failed to removed directory ....

If so, there is probably a directory under /run/timeshift which Linux thinks is busy .... and you can't delete it. I don't know what triggers this situation, but if you reboot that directory goes away and then (for me) all my snapshots appear properly.

Diagnosed this by building from source and adding a debug line to src/Core/Main.vala Line 4407 ... log_error(cmd3)

                            if (retval3 != 0){
                                    log_error("Failed to remove directory");
   >>>>> added debug line                                 log_error(cmd3);
                                    log_msg("Ret=%d".printf(retval3));

You now get a better error message .... for me the debug showed that the directory was /run/timeshift/3420 When I tried to remove it manually Linux reported it as 'device busy'

A side effect is that when this situation exists, new snapshots work but do not seem to appear in the display.

I suggest that the error messages be reviewed and when a command fails, the actual command is also logged with the error message.

DeMiro5001 commented 1 month ago

I am having this error message when list snapshots or trying to restore. Note I am new to timeshift and I am confortable with cli. My machine is an intel atom with 2G ram, 500G HDD. Os: debian 12 Filesystem: btrfs

I have created a snapshot some days ago, when I tried to restore it I get this error message.

output of `sudo timeshift --list --debug` ``` sudo timeshift --list --debug D: Main() D: D: Running Timeshift v22.11.2 D: D: Session log file: /var/log/timeshift/2024-05-16_21-26-57_list-snapshots.log D: Distribution: debian "12" D: DIST_ID: debian D: Main: check_dependencies() D: Main: add_default_exclude_entries() D: Main: add_default_exclude_entries(): exit D: update_partitions() D: df -T -B1 D: Device: get_disk_space_using_df(): 1 D: Device: get_mounted_filesystems_using_mtab(): 1 D: Device: get_filesystems(): 6 D: partition list updated D: detect_system_devices() D: / is mapped to device: /dev/sda1, UUID=7b5ab67a-4acd-476b-adce-e078a5da914c, subvol=@rootfs D: Searching subvolume for system at path: / D: Found subvolume: @rootfs, on device: /dev/sda1 D: Users: root me D: Encrypted home users: D: Encrypted home dirs: D: Encrypted private dirs: D: Main: load_app_config() D: Member not found in JSON object: snapshot_size D: Member not found in JSON object: snapshot_count App config loaded: /etc/timeshift/timeshift.json D: IconManager: init() D: found images directory: /usr/share/timeshift/images D: Main(): ok D: AppConsole: parse_arguments() D: Main: initialize_repo() D: backup_uuid=7b5ab67a-4acd-476b-adce-e078a5da914c D: backup_parent_uuid= D: Setting snapshot device from config file D: repo: creating from uuid D: SnapshotRepo: from_uuid(): RSYNC D: uuid=7b5ab67a-4acd-476b-adce-e078a5da914c D: SnapshotRepo: init_from_device() D: D: SnapshotRepo: unlock_and_mount_devices() D: device=/dev/sda1 D: SnapshotRepo: unlock_and_mount_device() D: device=/dev/sda1 D: Device: get_mounted_filesystems_using_mtab(): 1 D: ------------------ D: arg=7b5ab67a-4acd-476b-adce-e078a5da914c, device=/dev/sda1 D: / D: ------------------ D: Device: get_mounted_filesystems_using_mtab(): 1 Mounted '/dev/sda1' at '/run/timeshift/92137/backup' D: SnapshotRepo: load_snapshots() D: loading snapshots from '/run/timeshift/92137/backup/timeshift/snapshots': 1 found D: SnapshotRepo: unlock_and_mount_device(): exit D: Selected snapshot device: /dev/sda1 D: Free space: 467.5 GB D: SnapshotRepo: check_status() D: SnapshotRepo: available() D: is_available: ok D: SnapshotRepo: has_snapshots() D: SnapshotRepo: has_space() - 0 required (0 B) D: df -T -B1 '/dev/sda1' D: Device: get_disk_space_using_df(): 1 D: SnapshotRepo: check_status(): exit D: SnapshotRepo: init_from_device(): exit D: SnapshotRepo: from_uuid(): exit D: Main: initialize_repo(): exit D: AppConsole: start_application() D: SnapshotRepo: check_status() D: SnapshotRepo: available() D: is_available: ok D: SnapshotRepo: has_snapshots() D: SnapshotRepo: has_space() - 0 required (0 B) D: df -T -B1 '/dev/sda1' D: Device: get_disk_space_using_df(): 1 D: SnapshotRepo: check_status(): exit Device : /dev/sda1 UUID : 7b5ab67a-4acd-476b-adce-e078a5da914c Path : /run/timeshift/92137/backup Mode : RSYNC Status : OK 1 snapshots, 467.5 GB free D: SnapshotRepo: has_snapshots() Num Name Tags Description ------------------------------------------------------------------------------ 0 > 2024-05-13_23-14-29 O D: exit_app() D: crontab -l D: Failed to read cron tab D: crontab -l D: Failed to read cron tab D: unmount_target_device() D: clean_logs() D: rm -rf '/tmp/XJFyWOSt' D: cleanup_unmount_devices() D: df -T -B1 D: Device: get_disk_space_using_df(): 2 D: Device: get_mounted_filesystems_using_mtab(): 1 D: Device: get_filesystems(): 6 E: Failed to remove directory Ret=256 D: df -T -B1 D: Device: get_disk_space_using_df(): 2 D: Device: get_mounted_filesystems_using_mtab(): 1 D: Device: get_filesystems(): 6 E: Failed to remove directory Ret=256 D: df -T -B1 D: Device: get_disk_space_using_df(): 2 D: Device: get_mounted_filesystems_using_mtab(): 1 D: Device: get_filesystems(): 6 E: Failed to remove directory Ret=256 D: df -T -B1 D: Device: get_disk_space_using_df(): 2 D: Device: get_mounted_filesystems_using_mtab(): 1 D: Device: get_filesystems(): 6 E: Failed to remove directory Ret=256 D: df -T -B1 D: Device: get_disk_space_using_df(): 2 D: Device: get_mounted_filesystems_using_mtab(): 1 D: Device: get_filesystems(): 6 D: Found stale mount for device '/dev/sda1' at path '/run/timeshift/92137/backup' D: Unmounted successfully ```
output of `sudo timeshift --restore` ``` sudo timeshift --restore Mounted '/dev/sda1' at '/run/timeshift/92219/backup' Select snapshot: Num Name Tags Description ------------------------------------------------------------------------------ 0 > 2024-05-13_23-14-29 O Enter snapshot number (a=Abort, p=Previous, n=Next): 0 ****************************************************************************** To restore with default options, press the ENTER key for all prompts! ****************************************************************************** Press ENTER to continue... Re-install GRUB2 bootloader? (recommended) (y/n): y Select GRUB device: Num Device Description ------------------------------------------------------------------------------ 0 > sda ATA WDC WD5000BPVT-22HXZT1 [MBR] 1 > sda1 btrfs, 490.0 GB GB [ENTER = Default (/dev/sda), a = Abort] Enter device name or number (a=Abort): 0 ****************************************************************************** GRUB Device: /dev/sda ****************************************************************************** ====================================================================== WARNING ====================================================================== Data will be modified on following devices: Device Mount ------------------ ----- /dev/sda1(@rootfs) / Please save your work and close all applications. System will reboot after files are restored. ====================================================================== DISCLAIMER ====================================================================== This software comes without absolutely NO warranty and the author takes no responsibility for any damage arising from the use of this program. If these terms are not acceptable to you, please do not proceed beyond this point! Continue with restore? (y/n): y E: Failed to mount device '/dev/sda1' at mount point '/run/timeshift/92219/restore/' E: mount: /run/timeshift/92219/restore: échec de l’appel système mount(2) : Aucun fichier ou dossier de ce type. dmesg(1) peut avoir plus d'informations après un échec de l'appel système du montage. E: Failed to remove directory Ret=256 E: Failed to remove directory Ret=256 E: Failed to remove directory Ret=256 E: Failed to remove directory Ret=256 E: Failed to remove directory Ret=256 ```