Freighter is a command-line utility to move files to/from storage backends in a convenient and efficient manner.
Use cases include:
- Restoring database backup files to a cloud compute instance
- Uploading local files to Dropbox for safe storage
- Downloading configuration files to a host from a VCS such as Github
- Dropbox (v2 API)
- Github (v3 API)
Freighter will firstly attempt to read a .freighter configuration file with any of the following supported extensions: json, toml, yaml, yml, properties, props, prop, hcl
This configuration file currently supports two keys:
- Provider: Type of storage provider, i.e., dropbox or github.
- Token: Access token to storage provider's API.
Example file:
provider: dropbox
token: mydropboxtoken
By default, Freighter assumes the presence of the configuration file in the /tmp directory; if it's located elsewhere it must be specified via the --config flag.
For docker, this file can be mounted as a secret (only compatible with swarm) or a regular volume file mapping (both docker run and swarm compatible)
If the configuration file is not present or is missing keys, Freighter will fall back to the following environment variables:
- FREIGHTER_PROVIDER
- FREIGHTER_TOKEN
With Docker Swarm and secret-mapped YML configuration file in non-default location:
docker service create -u [USER] \
--mount type=bind,source=[LOCAL_VOLUME_MAPPING],destination=/restore \
--secret freighter.yml \
opinari/freighter --config /run/secrets/freighter.yml restore REMOTE_FILE_PATH /restore/LOCAL_FILE_PATH With Docker and environment variables:
docker run -u [USER] \
-v [LOCAL_VOLUME_MAPPING]:/restore \
-e FREIGHTER_PROVIDER=[FREIGHTER_PROVIDER] \
-e FREIGHTER_TOKEN=[FREIGHTER_TOKEN] \
opinari/freighter restore REMOTE_FILE_PATH /restore/LOCAL_FILE_PATH With native binary and configuration file in default location:
./freighter restore FROM_REMOTE_PATH TO_LOCAL_PATHWith native binary and environment variables:
env FREIGHTER_PROVIDER=[FREIGHTER_PROVIDER] FREIGHTER_TOKEN=[FREIGHTER_TOKEN] ./freighter restore FROM_REMOTE_PATH TO_LOCAL_PATHWith Docker Swarm and secret-mapped YML configuration file in default location:
docker service create -u [USER] \
--mount type=bind,source=[LOCAL_VOLUME_MAPPING],destination=/backup \
--secret source=.freighter.yml,target=/tmp/.freighter.yml \
opinari/freighter backup /backup/LOCAL_FILE_PATH REMOTE_FILE_PATH With Docker and environment variables:
docker run -u [USER] \
-v [LOCAL_VOLUME_MAPPING]:/backup \
-e FREIGHTER_PROVIDER=[FREIGHTER_PROVIDER] \
-e FREIGHTER_TOKEN=[FREIGHTER_TOKEN] \
opinari/freighter backup /backup/LOCAL_FILE_PATH REMOTE_FILE_PATH With native binary and TOML configuration file in non-default location:
./freighter --config /home/core/freighter.toml backup FROM_LOCAL_PATH TO_REMOTE_PATHWith native binary and environment variables (Dropbox used as an example):
env FREIGHTER_PROVIDER=dropbox FREIGHTER_TOKEN=my_dropbox_access_token ./freighter backup FROM_LOCAL_PATH TO_REMOTE_PATHWith Docker Swarm, environment variable for provider and secret configuration file for token in non-default location:
docker service create -u [USER] \
--env FREIGHTER_PROVIDER=[FREIGHTER_PROVIDER] \
--mount type=bind,source=[LOCAL_VOLUME_MAPPING],destination=/age \
--secret token.yml \
opinari/freighter --config /run/secrets/token.yml age REMOTE_FILE_PATH --ouput /age/OUTPUT_FILE_PATH With native binary and configuration file in default location writing to output file:
./freighter age REMOTE_FILE_PATH --output /tmp/ageWith native binary and environment variables writing to stdout:
env FREIGHTER_PROVIDER=[FREIGHTER_PROVIDER] FREIGHTER_TOKEN=[FREIGHTER_TOKEN] ./freighter age REMOTE_FILE_PATHWith Docker Swarm and environment variables:
docker service create -u [USER] \
--env FREIGHTER_PROVIDER=[FREIGHTER_PROVIDER] \
--env FREIGHTER_TOKEN=[FREIGHTER_TOKEN] \
opinari/freighter delete REMOTE_FILE_PATHWith native binary and configuration file in default location, deleting a single file:
./freighter delete REMOTE_FILE_PATHWith native binary and environment variables, deleting multiple files:
env FREIGHTER_PROVIDER=[FREIGHTER_PROVIDER] FREIGHTER_TOKEN=[FREIGHTER_TOKEN] ./freighter delete /remote/file1.tar.gz /remote/other/file2.tar.gz /remote/oldfile.tar.gz