Upload and download files easily between Local/SFTP/Cloud storage using rclone
Project description
Prefect Managed File Transfer
Turn a prefect.io server into a managed file transfer solution. UI and Programatic creation of cron style jobs (aka Flows!) to upload and download files easily between servers. Support local, SFTP remotes plus any Cloud storage supported by rclone - so thats aws, azure, google, sharepoint, and many more out of the box.
Using prefect for managed file transfer means retries, logging, multi node and high availability come as standard - turning prefect into a reliable enterprise ready file transfer solution.
This package is not the fastest solution to move files around, but it prioritises reliability and ease of use, making it an excellent choice for replacing both quick cron job copy scripts and enterprise managed file transfer applicances.
Key features
- Copy and move files between almost any storage system easily.
- Reliable file moving with checksumming, file size checking etc.
- Smart and safe moving - settings to allow/block overwriting and to only copy files if they are new or changed.
- Unzip/Untar compressed folders after downloading them.
- Repath files as you move them.
- Complex filtering and ordering of files - by path, age, size etc. Pattern matching with regular expressions.
- Leverage Prefect.IO built in scheduling and orchestration capabilities:
- Transfer files on complex cron schedules
- notifications on success/failure - slack, email, etc
- Highly available server architecture - database server + multi-node workers and front ends.
Example use cases:
- Once per day SSH into my database server and copy the latest *.bkup file to a central storage location.
- Monitor a local network share directory for new files and automatically upload them to a cloud storage bucket.
- Schedule a weekly job to synchronize files between two remote servers.
- Move log files from a SSH available web server older than 30 days to a cold storage location.
- Copy file yyyy-MM-dd.zip from a remote server, where yyyy-MM-dd matches todays date, to a local directory and then unzip it.
- Download any file in an S3 bucket larger than 1GB and store it in a local directory.
Installation
Install prefect-managedfiletransfer with pip. (Requires an installation of Python 3.10+.)
pip install prefect-managedfiletransfer
# or
uv add prefect-managedfiletransfer
We recommend using a Python virtual environment manager such as uv, pipenv, conda or virtualenv.
In one (venv) terminal start a prefect server with logs enabled
export PREFECT_LOGGING_LEVEL="INFO"
export PREFECT_LOGGING_EXTRA_LOGGERS="prefect_managedfiletransfer"
prefect server start
# OR uv run prefect server start
There are many ways to manage infrastructure and code with prefect - here we demonstate starting a local worker:
export PREFECT_API_URL=http://127.0.0.1:4200/api
# or perhaps export PREFECT_API_URL=http://host.docker.internal:4200/api
export PREFECT_LOGGING_EXTRA_LOGGERS="prefect_managedfiletransfer"
export PREFECT_LOGGING_LEVEL="INFO"
# [Optional] add all logs: export PREFECT_LOGGING_ROOT_LEVEL="INFO"
prefect worker start --pool 'default-pool' --type process
# OR prefect worker start --pool 'default-pool' --type docker
Install the blocks using the prefect CLI
prefect block register -m prefect_managedfiletransfer
And then deploy the flows.
# deploy the flows to run locally
python -m prefect_managedfiletransfer.deploy --local
# OR deploy to run with a docker image - see deploy.py
python -m prefect_managedfiletransfer.deploy --docker
# or a version of the above using uv run:
uv run python -m prefect_managedfiletransfer.deploy --local
uv run python -m prefect_managedfiletransfer.deploy --docker
Visit the server UI http://localhost:4200.
- Create 2 blocks, one source and one destination
- On the deployments page start a
transfer_files_flow. Configure your flow run to copy/move files between the 2 blocks.
Installation via docker
# run prefect server in a container port-forwarded to your local machine’s 4200 port:
docker run -d -p 4200:4200 prefecthq/prefect:3-latest -- prefect server start --host 0.0.0.0
List of components
Blocks
- ServerWithBasicAuthBlock - A block for connecting to a server using basic authentication.
- ServerWithPublicKeyAuthBlock - A block for connecting to a server using public key authentication.
- RCloneConfigFileBlock - A block for managing RClone configuration files.
Tasks
- list_remote_files_task - A task for listing files in a remote directory.
- download_file_task - A task for downloading a single file from a remote server.
- upload_file_task - A task for uploading a single file to a remote server.
- [TODO] delete_file_task
Flows
- transfer_files_flow - a fully featured flow for transferring files between different storage locations.
- upload_file_flow - a flow for uploading a file to a remote server. Supports pattern matching by date
Feedback
If you encounter any bugs while using prefect-managedfiletransfer, feel free to open an issue in the prefect-managedfiletransfer repository.
Feel free to star or watch prefect-managedfiletransfer for updates too!
Contributing
If you'd like to help contribute to fix an issue or add a feature to prefect-managedfiletransfer, please propose changes through a pull request from a fork of the repository.
Here are the steps:
- Fork the repository
- Clone the forked repository
- Install the repository and its dependencies:
# install uv first, then
uv sync
You can also access all the prefect CLI tooling inside a uv managed venv
uv venv
source .venv/bin/activate
prefect server start
- Make desired changes
- Add tests
- Insert an entry to CHANGELOG.md
- Install
pre-committo perform quality checks prior to commit:
pre-commit install
- use the build script to run all the checks and tests:
./build.sh
git commit,git push, and create a pull request
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
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 prefect_managedfiletransfer-0.1.0.tar.gz.
File metadata
- Download URL: prefect_managedfiletransfer-0.1.0.tar.gz
- Upload date:
- Size: 71.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b367fd9feed53b3f7c9aac734779ce2cc07727de52937fec0d06472453621adb
|
|
| MD5 |
d87f45328914328ec08af9b8351d831a
|
|
| BLAKE2b-256 |
5301d92fbf18613b000c8a6eeb6e2d291c4be073aa347dbbec54ac9df0c56893
|
Provenance
The following attestation bundles were made for prefect_managedfiletransfer-0.1.0.tar.gz:
Publisher:
release.yml on ImperialCollegeLondon/prefect-managedfiletransfer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prefect_managedfiletransfer-0.1.0.tar.gz -
Subject digest:
b367fd9feed53b3f7c9aac734779ce2cc07727de52937fec0d06472453621adb - Sigstore transparency entry: 385720262
- Sigstore integration time:
-
Permalink:
ImperialCollegeLondon/prefect-managedfiletransfer@0976bca932b43c56f92e5dca3875684114ed0cdb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ImperialCollegeLondon
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0976bca932b43c56f92e5dca3875684114ed0cdb -
Trigger Event:
push
-
Statement type:
File details
Details for the file prefect_managedfiletransfer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: prefect_managedfiletransfer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 71.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6967611aa7277ce5f7d79d3a0b81389c63de88a731a9ee799afbb07371683f8d
|
|
| MD5 |
78fc79608876bf4d0bb5e4fa9ae69de3
|
|
| BLAKE2b-256 |
2417eb9ff5f47d5c6894c334ff52d8f83897fe6c2375924c18c1a419efbd7e65
|
Provenance
The following attestation bundles were made for prefect_managedfiletransfer-0.1.0-py3-none-any.whl:
Publisher:
release.yml on ImperialCollegeLondon/prefect-managedfiletransfer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prefect_managedfiletransfer-0.1.0-py3-none-any.whl -
Subject digest:
6967611aa7277ce5f7d79d3a0b81389c63de88a731a9ee799afbb07371683f8d - Sigstore transparency entry: 385720274
- Sigstore integration time:
-
Permalink:
ImperialCollegeLondon/prefect-managedfiletransfer@0976bca932b43c56f92e5dca3875684114ed0cdb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/ImperialCollegeLondon
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0976bca932b43c56f92e5dca3875684114ed0cdb -
Trigger Event:
push
-
Statement type: