RestorationOfErathia (restoration_of_erathia v0.1.1) View Source
Documentation for RestorationOfErathia
.
The module is designed to assist with restoration of deleted files from hdd.
It is assumed that a tool similar to photorec is used to restore the deleted files. The documentation for using photorec can be found here: https://www.cgsecurity.org/testdisk.pdf
Two things need to be configured: folder path to folder where restored data is and formats that should be separated out of the rest of the restored data.
Link to this section Summary
Functions
Removes duplicated files from all the folders present in a given path
Given 2 folder paths, unique and duplicate, finds all files in duplicate folder that already exist in unique folder, based on hashes. Removes all the files with matching hashes from duplicate folder.
Removes duplicated files inside a folder (using file hash)
Finds all the files that have the specified extension format in a directory and moves them to a directory named after the extension format. Moves all files with unspecified extensions to a merged folder. Test requires specific path setting in module constants.
Removes all empty folders from a given path
Runs the entire helper pipeline
Link to this section Functions
Removes duplicated files from all the folders present in a given path
deduplicate_between_folders(unique_folder_path, duplicate_folder_path)
View SourceGiven 2 folder paths, unique and duplicate, finds all files in duplicate folder that already exist in unique folder, based on hashes. Removes all the files with matching hashes from duplicate folder.
Examples
iex> r = RestorationOfErathia
iex> {:ok, wd} = File.cwd()
iex> File.mkdir("#{wd}/tmp")
iex> File.touch("#{wd}/tmp/test.txt")
iex> File.mkdir("#{wd}/tmp2")
iex> File.cp("#{wd}/tmp/test.txt", "#{wd}/tmp2/test.txt")
iex> r.deduplicate_between_folders("#{wd}/tmp", "#{wd}/tmp2")
iex> File.rm("#{wd}/tmp/test.txt")
iex> File.rmdir("#{wd}/tmp")
iex> File.rmdir("#{wd}/tmp2")
:ok
Removes duplicated files inside a folder (using file hash)
Examples
iex> r = RestorationOfErathia
iex> {:ok, wd} = File.cwd()
iex> File.mkdir("#{wd}/tmp")
iex> File.touch("#{wd}/tmp/test.txt")
iex> File.cp("#{wd}/tmp/test.txt", "#{wd}/tmp/test2.txt")
iex> r.deduplicate_folder("#{wd}/tmp")
iex> File.rm("#{wd}/tmp/test2.txt")
iex> File.rmdir("#{wd}/tmp")
:ok
Finds all the files that have the specified extension format in a directory and moves them to a directory named after the extension format. Moves all files with unspecified extensions to a merged folder. Test requires specific path setting in module constants.
Examples
iex> r = RestorationOfErathia
iex> {:ok, wd} = File.cwd()
iex> File.mkdir("#{wd}/tmp")
iex> File.touch("#{wd}/tmp/test")
iex> r.move_to_dir("#{wd}/tmp/test", "*")
iex> File.rm("#{wd}/tmp/merged/test")
iex> File.rmdir("#{wd}/tmp/merged")
iex> File.rmdir("#{wd}/tmp")
:ok
Removes all empty folders from a given path
Examples
iex> r = RestorationOfErathia
iex> {:ok, wd} = File.cwd()
iex> File.mkdir("#{wd}/tmp")
iex> File.mkdir("#{wd}/tmp2")
iex> r.remove_empty_folders("#{wd}")
Runs the entire helper pipeline:
- Separates data according to folders according to formats.
- Merges all unset formats to a single folder.
- Deduplicates files within the folders.
- Removes empty folders