setup-store.js
: The script has the responsibility to create the needed buckets in Google Storage API. There is a list in the script that the user can modify and all the needed buckets will be created on his own Google Storage service.compress-files.js
: With this script is possible to compress files and directories and copy those .zip files to the foldercompress_files
.upload.js
: After the.zip
files are created, with the defined structure, the latest version of those files are uploaded to Google Storage, depending on who bucket it belongs.main.js
: Its the script that automatically, depending of the fixed time, executes the previous script, and saves the latest information of the database.
Binary Coffee API application is using the framework strapi.io. This framework organizes the information in two ways:
- Database information
- Static files, like images.
All the previous information is saved on independents volumes in the hosting, and it's easy to share these volumes between those Docker containers and the container of the current application. So, this means that the data saved in Google Storage is all the images that the application contains, and the daily backups of the database.
Well, in order to reuse the code, you need to adapt the scripts to your Business Logic, and use your personal store-key.json (generate from google API) that allow you to interact with your Google Storage session.
Currently, the only environment variables in use, are when the user starts the application with Docker. Those variables are:
EXTERNAL_IMAGES_PATH
: route to the external directory where the images to save are.EXTERNAL_BACKUPS_PATH
: route to the folder where the DB backups are.EXTERNAL_COMPRESS_FILES_PATH
: route where the.zip
files are going to be saved.
Locally
npm start
Docker
docker-compose up -d
@google-cloud/storage
: Google Storage API framework for NodeJSarchiver
: Dependency for compress files and directoriesnode-cron
: Library for manage cronjob tasks in NodeJS
All contributions are welcome