mirror-to-S3 - mirror an index page into an S3 bucket
Project description
mirror_to_s3
A Python tool to mirror a HTTP directory listing into an S3 bucket.
By Dale Magee
Developed for Saber Astronautics (https://saberastro.com)
and released as FOSS with their blessing - thanks!
This tool allows you to archive a number of sources into an S3 bucket, checking whether each
file exists in the destination bucket and only retrieving files which are missing
(or marked to be refreshed each run).
Note that this tool does not (presently) check file sizes or dates, only whether a file with
the same name exists at the destination.
mirror_to_s3 is intended to be fast and robust, and is designed to be able to mirror large
data sets. It features concurrent downloads and has been tested with
CONFIGURATION
Program Configuration is done via environment variables and/or .env file.
The following env vars are required:
AWS_ACCESS_KEY_ID string AWS Access Key
AWS_SECRET_ACCESS_KEY string AWS Secret Key
S3_BUCKET string Name of S3 bucket to use. You'll need read/write access to this bucket.
You must provide at least one of CONTACT_EMAIL or USER_AGENT:
USER_AGENT string User Agent to send when performing HTTP requests
CONTACT_EMAIL email Contact Email address to be used in user agent.
The following settings are optional:
JSON_LOG True/Yes/1 Use the optional (proprietary) jsonlog library. Default False
LOG_LEVEL string Logging Level. Default INFO. Valid options: VERBOSE/DEBUG/INFO/WARN
S3_ENDPOINT url Endpoint to use for S3-compatible server (minio, mega, etc)
SOURCES_FILE path Location of the sources.yaml file to use. If not provided the program
will look for a file named sources.yaml in a) the current directory
b) the same directory as archiver.py c) the parent of that
MAX_DOWNLOADS int maximum number of concurrent downloads allowed
DRY_RUN bool if True, nothing will be downloaded. Useful for testing/debugging
See example.env for more info
You'll also need a sources.yaml file specifying what sources you want to archive into your S3 bucket.
This yaml file should contain a list of sources, each of which must have:
name string A human-readable name for the source
The yaml file must provide one of:
index_url url The top-level url. Must be an "index of <path>" page. Must end with a slash.
file_url url The URL for a single file to be mirrored. The basename of this file will be used
when saving in the dest_dir
The yaml file may also provide the following:
dest_dir string Name of "directory" to store files from this source in. If not provided, a
destination dir will be derived from the name.
You may include {DATE} in the dest_dir, this will be replaced the current date,
formatted YYYY_MM_DD
include list List of glob expressions indicating which files/directories to archive.
if an include list is provided, only matching items will be archived.
exclude list List of glob expressions indicating files/directories to exclude from archiving.
refresh list List of glob expressions indicating files/directories to archive on every run,
i.e items in this list will be archived regardless of whether they already exist
in the destination bucket. Used for files which are updated regularly at the source.
see sources.example.yaml for more info
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mirror_to_s3-0.0.2.tar.gz
(16.0 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 mirror_to_s3-0.0.2.tar.gz.
File metadata
- Download URL: mirror_to_s3-0.0.2.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd82d99a39f315f98f1595393e4ff1bd229a9147e1b9cc45d632ee15c90dd218
|
|
| MD5 |
036c2dc60f5b27a40a5951f5dcf1cbb0
|
|
| BLAKE2b-256 |
01d0cf716503fd0fa938be6cf79bf642a2cc41ae4251eea14ea7d78b396bd61b
|
File details
Details for the file mirror_to_s3-0.0.2-py3-none-any.whl.
File metadata
- Download URL: mirror_to_s3-0.0.2-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b98d77740888d9186e0f7e506de53b81f8227bf6e8d941bcd4b39b7e192372ae
|
|
| MD5 |
d11bbdf1117a2a1391e4eb6939d3f9dc
|
|
| BLAKE2b-256 |
1060e083b359053b8d6276d031fa54281eb02b279892c5421c8a7226ffac942c
|