基于rclone的Docker镜像,可按cron计划执行文件同步,并集成healthchecks.io监控功能,支持多种存储服务间的文件传输与定时同步。
docker-rclone
Docker image to perform a http://rclone.org sync based on a cron schedule, with https://healthchecks.io monitoring.
rclone is a command line program to sync files and directories to and from:
- Google Drive
- Amazon S3
- Openstack Swift / Rackspace cloud files / Memset Memstore
- Dropbox
- Google Cloud Storage
- Amazon Drive
- Microsoft OneDrive
- Hubic
- Backblaze B2
- Yandex Disk
- SFTP
- FTP
- HTTP
- The local filesystem
Usage
Configure rclone
rclone needs a configuration file where credentials to access different storage provider are kept.
By default, this image uses a file /config/rclone.conf and a mounted volume may be used to keep that information persisted.
A first run of the container can help in the creation of the file, but feel free to manually create one.
$ mkdir config $ docker run --rm -it -v $(pwd)/config:/config pfidr34/rclone
Perform sync in a daily basis
A few environment variables allow you to customize the behavior of rclone:
SYNC_SRCsource location forrclone sync/copy/movecommandSYNC_DESTdestination location forrclone sync/copy/movecommandSYNC_OPTSadditional options forrclone sync/copy/movecommand. Defaults to-vSYNC_OPTS_EVALfurther additional options forrclone sync/copy/movecommand. The variables and commands in the string are first interpolated like in a shell. The interpolated string is appended to SYNC_OPTS. That means '--backup-dir /old`date -I`' first evaluates to '--backup-dir /old2019-09-12', which is then appended to SYNC_OPTS. The evaluation happens immediately before rclone is called.SYNC_ONCEset variable to only run the sync one time and then exit the containerRCLONE_CMDset variable tosynccopyormovewhen running rclone. Defaults tosyncRCLONE_DIR_CMDset variable tolsorlsffor source directory check style. Defaults tolsRCLONE_DIR_CHECK_SKIPset variable to skip source directory check before sync. Use with cautionCRONcrontab schedule0 0 * * *to perform sync every midnight. Also supprorts cron shortcuts:@yearly@monthly@weekly@daily@hourlyCRON_ABORTcrontab schedule0 6 * * *to abort sync at 6amFORCE_SYNCset variable to perform a sync upon bootCHECK_URLhttps://healthchecks.io url or similar cron monitoring to perform aGETafter a successful syncFAIL_URLFail URL to perform aGETafter unsuccessful execution. By default this isCHECK_URLwith appended "/fail" at the endSYNC_OPTSadditional options forrclone synccommand. Defaults to-vOUTPUT_LOGset variable to output log file to /logsROTATE_LOGset variable to delete logs older than specified days from /logsTZset the timezone to use for the cron and logAmerica/ChicagoUIDset variable to specify user to run rclone as. Must also use GID.GIDset variable to specify group to run rclone as. Must also use UID.
When using UID/GID the config and/or logs directory must be writeable by this UID
bash$ docker run --rm -it -v $(pwd)/config:/config -v /path/to/source:/source -e SYNC_SRC="/source" -e SYNC_DEST="dest:path" -e TZ="America/Chicago" -e CRON="0 0 * * *" -e CRON_ABORT="0 6 * * *" -e FORCE_SYNC=1 -e CHECK_URL=https://hchk.io/hchk_uuid pfidr34/rclone
See https://rclone.org/commands/rclone_sync/ for source/dest syntax and additional options.
Changelog
- 11/19/2019:
- Added arm 32/64 support
- 11/18/2019:
- Add support for UID/GID
- 11/06/2019:
- Update to latest Rclone (v1.50.1)
- 10/27/2019:
- Update to latest Rclone (v1.50.0)
- 10/07/2019:
- Update to latest Rclone (v1.49.5)
- 10/01/2019:
- Update to latest Rclone (v1.49.4)
- 09/23/2019:
- Add environment variable SYNC_ONCE
- 09/19/2019:
- Add environment variable SYNC_OPTS_EVAL
- 09/17/2019:
- Update to latest Rclone (v1.49.3)
- 09/10/2019:
- Regression on log rotation
- 09/09/2019:
- Update to latest Rclone (v1.49.2)
- 08/29/2019:
- Update to latest Rclone (v1.49.1)
- 08/20/2019:
- Add start command for healthchecks.io calls
- Add debug messages for healthchecks.io calls
- 08/19/2019:
- Correct log rotation when there are no logs
- 07/18/2019:
- Optimizations to dockerfile
- 06/22/2019:
- Update to latest Rclone (v1.48.0)
- 05/01/2019:
- Initial release
Credit to Brian J. Cardiff for the orginal project @ https://github.com/bcardiff/docker-rclone
镜像拉取方式
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
DockerHub 原生拉取命令
用户好评
来自真实用户的反馈,见证轩辕镜像的优质服务