You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -54,20 +54,30 @@ First, pull the latest docker image:
54
54
```bash
55
55
docker pull openbridge/ob_bulkstash
56
56
```
57
-
This will pull the latest version by default. However, as part of the `hooks/build` process we publish a number of older versions of rclone. If you want to see the available versions, check out Docker Hub [`openbridge/ob_bulkstash`](https://hub.docker.com/r/openbridge/ob_bulkstash/tags/). For example, if you wanted to run version `1.19`, then pull that version like this:
57
+
This will pull the latest version by default. However, as part of the `hooks/build` process we publish a number of older versions of rclone. If you want to see the available versions, check out Docker Hub [`openbridge/ob_bulkstash`](https://hub.docker.com/r/openbridge/ob_bulkstash/tags/). For example, if you wanted to run version `1.47`, then pull that version like this:
58
58
59
59
```bash
60
-
docker pull openbridge/ob_bulkstash:1.46
60
+
docker pull openbridge/ob_bulkstash:1.47.0
61
61
```
62
62
Additional pre-built versions are tagged and available for use: https://hub.docker.com/r/openbridge/ob_bulkstash/tags/
63
63
64
64
If you want to build your own image, you need to pass the version you want to use:
Got your version setup? Great. Next, we need to define a configuration for remote storage locations. The following demonstrates how to sync Amazon and Google cloud storages.
70
70
71
+
### Testing Your Build
72
+
The validate that your build worked correctly, you can run a simple check which will have rclone echo the version back to you.
73
+
74
+
If you run this `docker run openbridge/ob_bulkstash rclone -V` you should see the version displayed like this:
75
+
```Bash
76
+
rclone v1.47.0
77
+
- os/arch: linux/amd64
78
+
- go version: go1.12.4
79
+
```
80
+
If you see this, success! Your image is ready to go!
71
81
72
82
## Amazon and Google Examples
73
83
In our example we have a source of files at Amazon S3 and destination for those files at Google Cloud Storage location. This means we will need to set the configuration ENV variables for source and destination.
@@ -124,7 +134,7 @@ With your config setup, now you can run `rclone`!
Earlier we showed a simple rclone command to echo the version number:
166
+
```bash
167
+
docker run openbridge/ob_bulkstash rclone -V
168
+
```
155
169
156
170
### Using the Google AUTH file
157
171
Here is an example that mounts the Google auth file needed for service level accounts:
@@ -165,7 +179,17 @@ done
165
179
# Using `crond` Inside Docker
166
180
If you want to persist your container you can set it up to always be running with `crond` as a background process. While most everything is automated there are a few configuration items you need to set.
167
181
168
-
## Bring Your Own Crontab Configuration
182
+
**IMPORTANT**: This assumes you have a basic understanding of Docker and background processes. If you do not know what `--detach , -d` means then please review the Docker docs about running in detached mode (hint: this is how you run things in the background)
183
+
184
+
## Runtime Environment
185
+
Depending on your use of `CROND`, it may not have access to the OS defined `ENV` variables. As a convenience, the image will output these to a file:
186
+
187
+
```bash
188
+
printenv | sed 's/^\([a-zA-Z0-9_]*\)=\(.*\)$/export \1="\2"/g'| grep -E "^export RCLONE"> /cron/rclone.env
189
+
```
190
+
If needed, you can then import these variables into any scripts that you want to run in the container such as using something like `source /cron/rclone.env`.
191
+
192
+
## Option 1: Bring Your Own Crontab Configuration
169
193
170
194
### Step 1: Setup your `crontab.conf` config
171
195
Running `crond` requires a proper configuration file. You can easily add a crontab config file and have the container use it. A `crontab.conf` should look something like this:
You can let the image generate and run a command for you under `CROND`.
239
+
This is geared to running a single `CROND` task. If you want to run multiple tasks, it is best to choose **Option 1** which allows you more control over the number of tasks run.
213
240
214
-
Included in the image is a utility script that will run `rclone copy` and `rclone move`. It will also has a `foldersize` check in the event you want to trigger a `rclone move`. How is this helpful? If your disk is getting full this can trigger what amounts to be a cleanup task.
241
+
### Setting your `CROND` command
242
+
In your ENV, you need to set the desired command via `RCLONE_SYNC_COMMAND`. Here is an example command:
This is just an example command, it will likely vary according to what you are looking too run.
254
+
255
+
256
+
## IMPORTANT `crontab.conf` NOTE
257
+
Please note that if you set your own crontab config file via `RCLONE_CRONFILE=/cron/crontab.conf` it will take precedent over anything you pass via `-e` or set other environment variables.
258
+
259
+
## Understanding How To Run Docker and `CROND`
260
+
Here are a few examples of running Docker and `CROND` in the background. You can accomplish the same using `docker-compose`
You can see the process running in the background:
267
+
```bash
268
+
PID PPID USER STAT VSZ %VSZ CPU %CPU COMMAND
269
+
31 0 root R 1528 0% 3 0% top
270
+
1 0 root S 1516 0% 1 0% crond -f
271
+
```
272
+
Running in detached mode using the `rcron.sh` helper script. This will use Monit has the background process monitor to make sure `CROND` is always running:
Hopefully you get the point on how to do this. You have options, just make sure you understand the basics on how to run Docker in various contexts.
297
+
298
+
# Creating Your Own Scripts: The `/rclone.sh` Example
299
+
300
+
Included in the image is a utility script. You can use this as a robust example for creating your own. It highlights the potential to mount scripts like this into your container to run different types of operations.
301
+
302
+
**Note**: `rclone.sh` is provided as-is and has not been fully tested. Think of it as a proof-of-concept, not something you should blindly use.
303
+
304
+
## Overview
305
+
The script shows an example of how to run `rclone copy` and `rclone move`. It will also has a `foldersize` check in the event you want to trigger a `rclone move`. How is this helpful? If your disk is getting full this can trigger what amounts to be a cleanup task.
215
306
216
307
### Getting Started with `/rclone.sh`
217
-
If you want the image to use `/rclone.sh` make sure the required environment variables are set correctly. In your `ENV`, you need to set the following:
308
+
While the image contains `rclone.sh`, you will likely want to mount your own version of the script. For example;
Also, you need to make sure the image can use `/rclone.sh`. This means you need to make sure any required environment variables are set correctly. For example, in your `ENV`, you need to set the following for `rclone.sh`:
218
314
219
315
*`RCLONE_CROND_SCHEDULE` crontab schedule `* * * * *` to perform sync every midnight
220
316
*`RCLONE_CROND_SOURCE_PATH` source location for `rclone copy` command
Please note that if you set your own crontab config file via `RCLONE_CRONFILE=/cron/crontab.conf` it will take precedent over anything you set in these environment variables. The answer is simply to include all of these in your own config
You can setup SFTP remotes. This allows you to upload or download files from an SFTP server. You can also do server to server transfers between two remotes.
@@ -300,9 +387,14 @@ List a remote drive like this: `rclone lsd {remote name}:`
300
387
Replace `{remote name}` with your actual remote name. Using our Amazon example it would look like this
301
388
`rclone lsd MYS3:`
302
389
390
+
Using Docker this is a possible way to run the command:
391
+
```bash
392
+
docker run -env-file /env/my.env openbridge/ob_bulkstash rclone lsd MYS3:
Copy file name to clipboardExpand all lines: docker-entrypoint.sh
+25-39Lines changed: 25 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -12,58 +12,38 @@ set -o pipefail
12
12
13
13
functioncrond() {
14
14
15
-
if [[ -f${RCLONE_CRONFILE} ]];then
15
+
# Create the environment file for crond
16
+
if [[ -n"${RCLONE_CRONFILE:-}" ]] || [[ -n"${RCLONE_SYNC_COMMAND:-}" ]];then
16
17
17
-
# If using your own cron config, use that now else we create one for you
18
-
RCLONE_CRONFILE=/cron/crontab.conf
19
-
export RCLONE_CRONFILE
18
+
echo"OK CRON It is"
19
+
if [[ !-d /cron ]];then mkdir -p /cron;fi
20
20
21
-
else
21
+
RCLONE_CRONFILE=/cron/crontab.conf
22
+
# If using your own cron config, use that now else we create one for you
23
+
export RCLONE_CRONFILE
22
24
23
-
# For the use of /rclone.sh and crond
25
+
printenv | sed 's/^\([a-zA-Z0-9_]*\)=\(.*\)$/export \1="\2"/g'| grep -E "^export RCLONE"> /cron/rclone.env
24
26
25
-
if [[ -n"${RCLONE_CROND_SOURCE_PATH:-}" ]]|| [[ -n"${RCLONE_CROND_DESTINATION_PATH:-}" ]];then
27
+
if [[ -f /cron/rclone.env ]];thenecho"OK: The you set CROND to run. A ENV file was created here /cron/rclone.env. Continuing...";elseecho"ERROR: The CROND ENV is missing even though you want to run CROND. Please check your config file";fi
26
28
27
-
#if [[ ! -f /cron/rclone.env ]]; then exit 1; fi
28
-
if [[ !-d /cron ]];then mkdir -p /cron;fi
29
-
30
-
# Set a default if a schedule is not present
31
-
if [[ -z"${RCLONE_CROND_SCHEDULE:-}" ]];then RCLONE_CROND_SCHEDULE="0 0 * * *"&&export RCLONE_CROND_SCHEDULE;fi
32
-
33
-
if [[ !-z${RCLONE_CROND_SOURCE_SIZE} ]];then
34
-
{
35
-
echo'check program foldersize with path "/bin/bash -c '/rclone.sh foldersize'"'
36
-
echo' if status != 0 for 2 cycles then exec "/usr/bin/env bash -c '/rclone.sh run'"'
0 commit comments