pisync is a simple library to aid in writing incremental backup scripts to
local or remote machines. The only dependencies are rsync,
python >= v3.6, fabric, and ssh keys copied over to a unix
machine if doing a remote backup. Note: no dependencies are required on the
remote machine.
Installation
pip install pisync
Example Usage
from pisync import LocalConfig, RemoteConfig, backup
local_docs = LocalConfig(
source_dir="/home/ethan/Documents", # local machine
destination_dir="/tmp/backup_test", # local machine
exclude_file_patterns=[
"**/node_modules",
"junk/",
],
log_file="/tmp/backup-logs/backups.log" # local machine
)
remote_docs = RemoteConfig(
user_at_hostname="ethan@hydrogen.local", # remote machine
source_dir="/home/ethan/Documents", # local machine
destination_dir="/tmp/backup_test", # remote machine
exclude_file_patterns=[
"**/node_modules",
"junk/",
],
log_file="/tmp/backup-logs/backups.log" # local machine
)
backup(local_docs)
backup(remote_docs)
Also see an example config for how I backup my home server both locally and to an offsite raspberry pi.
Notes
Safety
- Creating a
LocalConfigorRemoteConfigobject will fail ifsource_dirordestination_dirdo not exist or are not directories. - If
destination_diris not empty, it is assumed that a previous backup exists.- The backup will not run if
destination_diris not empty and there is not a symlinkdestination_dir/latestpointing to the latest backup. - The contents of
source_dirare compared todestination_dir/latestduring the incremental backup and the changes are written todestination_dir/<current date/time>. - Therefore, you need to ensure that
destination_diris empty which will start a fresh complete backup, or you can manually create thedestination_dir/latestsymlink to continue incrementally.
- The backup will not run if
Logging
- By default, a default log file will be created (if it does not exists) and
appended to at
~/.local/share/backup/rsync-backups.log. - NOTE: If you run your script as
sudo, the home directory of the root user is probably/rootrather than your~/directory. - If you want the log file to still go the your home directory when you run as
root, use this
sudo -E python3 ./run_backups.py - You can also specify the log file location in your config.
- Hard coding the log file path solves some of the quirks that you can run into when using a cron job.
Running tests
The unit/integration tests require password-less login to localhost as the "remote" machine.
ssh-copy-id $USER@localhost
git clone https://github.com/erietz/pisync
cd pisync
pip install -e .
make test
Metadata
Release files for pisync 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pisync-0.0.9.tar.gz | 22.3 kB | Without provenance | Details for pisync-0.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pisync-0.0.9-py3-none-any.whl | Python 3 | none | any | Details for pisync-0.0.9-py3-none-any.whl |
Total release size: 42.9 kB
Release files / pisync-0.0.9.tar.gz
| Download URL | pisync-0.0.9.tar.gz |
|---|---|
| Size | 22.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de1a21df5efd43d3fce2aced6b621dbe99b7c0631ff9f01247aacdf52bbb4d36
|
|
BLAKE2b-256 checksum How to use checksums |
aaef8810edd32c2b814d82c4a62ff7b3ec65252882519a949dd23ff71c8fb307
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.0
|
Release files / pisync-0.0.9-py3-none-any.whl
| Download URL | pisync-0.0.9-py3-none-any.whl |
|---|---|
| Size | 20.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50cfcaaeb9effef8cd3f1b038d8d79b6839f13dcec31b8abaa3b3a01cd88e76f
|
|
BLAKE2b-256 checksum How to use checksums |
1a65f47a005a42a75930d077fee75955b68a6e67b16d3cfc748f885f38a10837
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.27.0
|
Security for pisync 0.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.