====== SnapRAID - Recover a Lost File ====== ===== Restore Files ===== To restore or undelete files to their previous state using the **-f**, **--filter** option : snapraid fix -f FILE **WARNING:** The **"fix"** command does not differentiate between errors and intentional modifications. * It unconditionally reverts the file state as at the last "sync". ---- ===== Restore Directories ===== snapraid fix -f DIR/ ---- ===== Restore Only Missing Files ===== To recover only accidentally deleted files inside a directory using the **-m**, **--filter-missing** option, that restores only missing files, leaving untouched all the others. snapraid fix -m -f DIR/ ---- ===== Restore All Deleted Files in All Drives ===== To recover all the deleted files in all the drives: snapraid fix -m ---- ===== Restore All Deleted Files on Data Disk d1 ===== To recover all the deleted files in a specific data disk: snapraid fix -m -d d1 ---- ===== Restore the contents of any specifically named directory in all drives ===== snapraid fix -m -f Test/ **NOTE:** This will recreate the contents of any folder named Test anywhere in the array. ---- ===== Get the absolute path from the file system perspective of any changes since the last sync ===== Find the absolute path of the file to be recovered. snapraid diff --test-fmt path returns: Loading state from /var/snapraid.content... Comparing... add /mnt/disk03/Dir1/Subdir1/TVShow1.mkv add /mnt/disk02/Dir2/Subdir2/TVShow2.mkv ... update /mnt/disk03/Dir3/Subdir3/TVShow3.mkv update /mnt/disk03/Dir3/Subdir3/TVShow4.mkv ... copy /mnt/disk02/Dir4/Subdir4/TVShow5.mkv -> /mnt/disk03/Dir4/Subdir4/TVShow5.mkv copy /mnt/disk02/Dir4/Subdir4/TVShow6.mkv -> /mnt/disk03/Dir4/Subdir4/TVShow6.mkv ... move /mnt/disk04/Dir5/Subdir5/TVShow7.mkv -> /mnt/disk04/Dir5/Subdir5x/TVShow7.mkv move /mnt/disk04/Dir5/Subdir5/TVShow8.mkv -> /mnt/disk04/Dir5/Subdir5x/TVShow8.mkv ... remove /mnt/disk01/Dir6/Subdir6/TVShow9.mkv remove /mnt/disk01/Dir6/Subdir6/TVShow10.mkv ... 550112 equal 294 added 1571 removed 5 updated 7 moved 1432 copied 0 restored There are differences! **NOTE:** The **--test-fmt path** option returns the absolute file paths instead of relative paths. Various changes are shown in the example above, including: * **Add** - Some files have been added since the last sync. * **Update** - Some files have been updated since the last sync. * **Copy** - Some files have been copied since the last sync. * **Move** - Some files have been moved since the last sync. * **Remove** - Some files have been removed since the last sync. ---- ===== Get the data disk from snapraids array perspective of any changes since the last sync ===== snapraid diff --test-fmt disk returns: Loading state from /var/snapraid.content... Comparing... add d3:Dir1/Subdir1/TVShow1.mkv add d2:Dir2/Subdir2/TVShow2.mkv ... update d3:Dir3/Subdir3/TVShow3.mkv update d3:Dir3/Subdir3/TVShow4.mkv ... copy d2:Dir4/Subdir4/TVShow5.mkv -> d3:Dir4/Subdir4/TVShow5.mkv copy d2:Dir4/Subdir4/TVShow6.mkv -> d3:Dir4/Subdir4/TVShow6.mkv ... move d4:Dir5/Subdir5/TVShow7.mkv -> d4:Dir5/Subdir5x/TVShow7.mkv move d4:Dir5/Subdir5/TVShow8.mkv -> d4:Dir5/Subdir5x/TVShow8.mkv ... remove d1:Dir6/Subdir6/TVShow9.mkv remove d1:Dir6/Subdir6/TVShow10.mkv ... 550112 equal 294 added 1571 removed 5 updated 7 moved 1432 copied 0 restored There are differences! **NOTE:** This returns the actual data disk where some change has occurred since the last sync. Various changes are shown in the example above, including: * **Add** - Some files have been added since the last sync. * **Update** - Some files have been updated since the last sync. * **Copy** - Some files have been copied since the last sync. * **Move** - Some files have been moved since the last sync. * **Remove** - Some files have been removed since the last sync. ---- ===== Check if a fix will work ===== snapraid check -v -m -f "/Dir1/Subdir1/" returns: Self test... Loading state from /var/snapraid.content... 551695 files 0 hardlinks 0 symlinks 970 empty dirs Searching disk d1... Excluding content '/mnt/disk01/.snapraid.content' Excluding directory '/mnt/disk01/lost+found' for rule 'exclude /lost+found/' Searching disk d2... Excluding directory '/mnt/disk02/lost+found' for rule 'exclude /lost+found/' Excluding content '/mnt/disk02/.snapraid.content' ... Selecting... /Dir1/Subdir1/ Scanning disk d1... Scanning disk d2... ... Using 8981 MiB of memory for the file-system. Initializing... Selecting... Checking... recoverable Dir1/Subdir1/File1.mkv recoverable Dir1/Subdir1/File2.mkv recoverable Dir1/Subdir1/File3.mkv ... 100% completed, 86580 MB accessed in 0:06 37633 errors 0 unrecoverable errors WARNING! There are errors! **NOTE:** This shows that these file are **recoverable**. * Notice that the command used does not use the absolute path, something like **/mnt/disk01/Dir1/Subdir1/**, but only the relevant path, **/Dir1/Subdir1/**. * Snapraid does not expect you to provide the absolute file system path when fixing files. ---- ===== Restore the contents of a directory ===== snapraid fix -m -f "/Dir1/Subdir1/" returns: Self test... Loading state from /var/snapraid.content... Searching disk d1... Searching disk d2... ... Selecting... Scanning disk d1... Scanning disk d2... ... Using 8981 MiB of memory for the file-system. Initializing... Selecting... Fixing... recovered Dir1/Subdir1/File1.mkv recovered Dir1/Subdir1/File2.mkv recovered Dir1/Subdir1/File3.mkv 100% completed, 86580 MB accessed in 0:06 37633 errors 37633 recovered errors 0 unrecoverable errors Everything OK **NOTE:** This should recover the directory and files. * Notice that the command used does not use the absolute path, something like **/mnt/disk01/Dir1/Subdir1/**, but only the relevant path, **/Dir1/Subdir1/**. * Snapraid does not expect you to provide the absolute file system path when fixing files. ----