A file and directory backup tool
Project description
file_dir_backup
file_dir_backup 是一个用于文件和目录备份的 Python 第三方库,支持全量备份和增量备份,同时支持 rsync 和 shutil 两种备份方法。
安装
pip install file_dir_backup
使用方法
命令行使用
# 查看帮助
$ file_dir_backup -h
usage: file_dir_backup [-h] [--backup-type {full,incremental}] [--method {rsync,shutil}] [--compress] [--bandwidth-limit BANDWIDTH_LIMIT] source destination
File and directory backup tool
positional arguments:
source Source directory to backup
destination Destination directory for backup
optional arguments:
-h, --help show this help message and exit
--backup-type {full,incremental}
Backup type: full or incremental
--method {rsync,shutil}
Backup method: rsync or shutil
--compress Compress data during transfer
--bandwidth-limit BANDWIDTH_LIMIT
Limit the bandwidth in KB/s
$ file_dir_backup /path/to/source /path/to/destination --backup-type full --method rsync --compress --bandwidth-limit 1000
# 全量同步示例:
#$ file_dir_backup /home/hujianli/test/ /home/hujianli/backup/ --backup-type full --method rsync --compress --bandwidth-limit 1000
# 或者
$ python -m file_dir_backup /path/to/source /path/to/destination --backup-type full --method rsync --compress --bandwidth-limit 1000
# 增量同步示例:
#$ python -m file_dir_backup /home/hujianli/test/ /home/hujianli/backup/ --backup-type incremental --method rsync --compress --bandwidth-limit 1000
使用配置文件
支持的配置文件查找规则:
- 环境变量
FILE_DIR_BACKUP_CONFIG ~/.file_dir_backup.cfg./etc/file_dir_backup.cfg/etc/file_dir_backup.cfg
配置文件格式,以/etc/file_dir_backup.cfg为示例:
[backup]
source = /home/hujianli/test
destination =/home/hujianli/backup
# 备份类型
backup_type = full
# 备份方法
method = rsync
# 是否传输过程中压缩数据
compress = true
# 传输限速
bandwidth_limit = 1000
Python 代码使用
from file_dir_backup import backup
backup('/path/to/source', '/path/to/destination', backup_type='full', method='rsync', compress=True, bandwidth_limit=1000)
测试
测试代码在 tests 目录下,使用 unittest 模块进行测试。
python -m unittest test.test_file_dir_backup
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
file_dir_backup-0.1.1.tar.gz
(6.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file file_dir_backup-0.1.1.tar.gz.
File metadata
- Download URL: file_dir_backup-0.1.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd6f797089d5ec4087882ed275aa0bfecc5acbe1f598c96d97d1c1ee1158d8a6
|
|
| MD5 |
2c2f65e284fe5f31ccf1f5a21950920f
|
|
| BLAKE2b-256 |
6579ba2c5d1982bc1e1f6b24fc704524039bc80cfd61bfaef26bc43b52fe8226
|
File details
Details for the file file_dir_backup-0.1.1-py3-none-any.whl.
File metadata
- Download URL: file_dir_backup-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6449898eff0cd3c67785c02ede958138f302b81f43af7ca94a768a090a3265a6
|
|
| MD5 |
15403ff04b58f5a7c6783b4c4e5855b1
|
|
| BLAKE2b-256 |
1eb00b502dde2d19724aad4747a3d74181b76c79692152b502efda4112caaddb
|