restorething是一个用于从syncthing版本控制存档还原文件的工具
restorething的Python项目详细描述
restorething是用于从同步对象还原文件的工具 版本控制存档。提供同步对象的路径restorething。 版本控制目录和日期,它将索引 版本控制为您存档和还原文件。
restorething具有多种还原模式和筛选功能 文件和目录。
恢复模式
restorething将使用以下模式还原文件
- 特定日期/时间之前/之后最近的文件(默认行为)
- 特定日期/时间之前最近的文件
- 特定日期/时间之后最近的文件
- 没有日期/时间限制的特定文件的所有实例
restorething有过滤选项
- 使用特定字符串筛选文件
- 使用特定字符串筛选目录
- 用特定字符串过滤dir和file
安装
restorething来自源代码
$ python setup.py sdist
$ pip install dist\restorething-x.x.x.tar.gz
restorething来自pypi
$ pip install restorething
用法
$ python -m restorething { date [ -hr{0-24} | -b | -a | -pm {int} | -ai {path and filename} | -vd {dir} | -rd {dir} | -dd {dir} | -df {filename} | -nf | -nd | -ic | -ns | [ -ff {string} | -fd {string} | -fb {path and filename} ] | -d | --version] }
Argument | Type | Format | Default | Description |
---|---|---|---|---|
date | integer | YYYYMMDD | No default value. Field must be supplied by user | Date to restore files, date will be used to find closest file before or after date |
-hr | integer | -hr {0-24} | 12 | Hour to compare file’s modification time |
-b | switch | -b | disabled | Limit restore of files to before the supplied date and hour |
-a | switch | -a | disabled | Limit restore of files to after the supplied date and hour |
-pm | integer | -pm {0-2147483647 hrs} | 0 | Limit restore of files to plus/minus hours each side of the supplied date and hour |
-ai | string | -ai {absolute path of file} | disabled | Recovers all versions of a file ignoring any date and times specified |
-vd | string | -vd {absolute or relative path of DIR} | .stversions | Sets the location of the syncthing versioning folder, by default script looks in directory script is run from |
-rd | string | -rd {absolute or relative path of DIR} | restore | Enables the ability to restore to a location other than the default |
-dd | string | -dd {absolute or relative path of DIR} | /home/name/.restorething | Enables the ability to use a database file in a different location, default behaviour is to store database file in users home directory |
-df | string | -df {filename} | restorething.db | Enables the ability to use a database file with a different name |
-nf | switch | -nf | disabled | Enables indexing archived files every time script is run, by default script will reuse existing DB file for 24 hours |
-nd | switch | -nd | disabled | Enables restoring files that have been deleted or changed due to renaming, by default deleted or renamed files are not included in restore |
-ic | switch | -ic | disabled | Enables restoring files that were marked as conflict files by syncthing and deleted by user, by default conflict files are not restored |
-ns | switch | -ns | disabled | Enables no simulation mode, default behaviour is to simulate restore, no simulation mode will copy files from syncthing archive to hard drive |
-ff | string | -ff {string} | disabled | Recovers a single version of any files matching the string supplied |
-fd | string | -fd {string} | disabled | Recovers a single version of all files in any DIR matching the string supplied |
-fb | string | -fb {absolute path of file} | disabled | Recovers a single version of a file matching the DIR and Filename |
-d | switch | -d | disabled | Enables debug output to console |
–version | switch | –version | disabled | Displays version |
默认行为
- 脚本的默认行为是查找最接近的文件 比提供的日期/时间早(早)。如果什么都找不到, 脚本查找比提供的文件年轻(之后)的最近文件 日期/时间。默认行为可以限制为正负小时 通过提供-pm {hours}参数或更改为仅查找 在提供的日期/时间之前或之后,使用-b或-a 分别标记。
- 如果未提供小时,则脚本使用的默认时间值为 下午12点。这可以通过使用-hr{0-24}参数进行更改
- 默认情况下,该脚本将始终模拟还原,为用户提供 查看任何检测到的警告的机会。通过提供-ns 标记,用户可以启用“无模拟”模式并执行 还原,不模拟,不撤消。
- 脚本将在 正在从中调用脚本并递归还原内部的所有文件 其中
- 如果未提供同步版本控制目录,则默认 行为是在调用脚本的目录中查找 从。
- 所有配置、日志和数据库文件都存储在用户家中 目录下名为.restorething的目录。
示例
如果找不到文件,请在2016年8月15日早上6点之前还原最近的文件 2016年8月15日早上6点后恢复壁橱文件。由于不供应 版本控制目录,需要从目录调用脚本 包含版本控制目录
$ python -m restorething 20160815 -hr 6
在2016年8月15日早上6点之后恢复最近的文件,如果没有找到文件,则没有 将还原文件。版本控制目录作为相对目录提供 从中调用脚本的路径。
$ python -m restorething 20160815 -hr 6 -a -vd sync/.stversions
在2016年8月15日早上6点之前恢复最近的文件,如果没有找到文件, 不会还原任何文件。版本控制目录作为相对目录提供 从中调用脚本的路径。
$ python -m restorething 20160815 -hr 6 -b -vd sync/.stversions
在2016年8月15日上午6点之前不超过10小时恢复最近的文件, 如果找不到文件restorething将查找壁橱文件否 2016年8月15日早上6点后超过10小时。版本控制目录是 作为调用脚本的相对路径提供。
$ python -m restorething 20160815 -hr 6 -pm 10 -vd sync/.stversions
还原目录中文件的所有实例 /some/important/directory/,命名为file.txt。当前脚本 限制是你必须提供一个日期,尽管它将被忽略。
$ python -m restorething 20160815 -ai /some/important/directory/file.txt