#!/bin/bash # From a cloud instance of Kobo-Docker, pull all of the attachments # and place them in a (much cheaper) Spaces filebin. # Assumes a Kobo-Docker instance running on a DO Ubuntu 16.04 instance # Need Amazon's CLI utility to manage transfers to/from spaces sudo apt install s3cmd # Add a key for the server in question to access your Spaces account: # https://www.digitalocean.com/docs/spaces/how-to/administrative-access/ # copy the key and secret token, and run (on the cloud server): s3cmd --configure # https://www.digitalocean.com/docs/spaces/resources/s3cmd/ # then you have to edit the config file at ~.s3cfg nano .s3cfg # Change host_base to appropriate example: nyc3.digitaloceanspaces.com # and host_bucket example: %(bucket)s.nyc3.digitaloceanspaces.com #Navigate to the folder containing the files cd kobo-docker/.vols/kobocat_media_uploads/$USER/attachments/ # Run GNU Screen so that you can close your terminal window without # stopping all of the transfers in a moment screen # start the transfers for i in $(find . -name *.jpg); do s3cmd put $i s3://ivan-filebin/FOLDER/; done; # You can then shut down that terminal and it will continue working (because of Screen) # later, go back into the server and launch a permission change to make the images public nohup s3cmd setacl s3://ivan-filebin/FOLDER --acl-public --recursive & # Again, you can shut down your terminal without interrupting the process (because of nohup) # and you can see the progress by doing tail -f nohup.out