Code Monkey home page Code Monkey logo

qcloudbackup's Introduction

donate

qcloudbackup

Automated cyclic-backup script for CVM as snapshots for specified storageId on QCloud implemented in NodeJS.

What It Can Do

Script will check first if creating a snapshot for specified storageId will require a deletion of existing snapshot or not. QCloud limits number of snapshots to be number of harddisk * 7. Then it will create a snapshot.

It will delay for specified amount of time before attempting to create a snapshot. This is due to consecutive creation of snapshot might be affected by previous un-complete operation even on different storage.

How To

Notifying of Backing up Result (optional)

To be able to notify successful, or failed message to your WeChat account via your WeChat Official/Subscription account with granted permission to send templated message. Then defines all of the following settings.

  • WECHAT_APPID=<your app id>

    Check at mp.weixin.qq.com for your WeChat official / subscription account.

  • WECHAT_APPSECRET=<your app secret>

    Check at mp.weixin.qq.com for your WeChat official / subscription account.

  • WECHAT_SU_OPENID=<user open id to receive msgs>

    You can find out what is your open id attached to your WeChat official / subscription account you followed by listing followers list via Follow List API.

  • WECHAT_SUCCESS_TEMPLATE_ID=<your template id>

    Check at mp.weixin.qq.com for Template Message section (you might need to apply to grant this ability). Then add a template that has at least 2 keywords, with 1 remark.

  • WECHAT_FAIL_TEMPLATE_ID=<your template id>

    Check at mp.weixin.qq.com for Template Message section (you might need to apply to grant this ability). Then add a template that has at least 4 keywords, with 1 remark.

You need to set all of above environment variables in order to make it works.

Run the Program

  1. Install and configure qcloudcli properly. See installation of qcloudcli, and how to configure.

  2. Modify parameters in index.js file.

    • storageIds -> define storageId to apply for backup. You need to define what's yours here.

      You can loook for storageIds easily on QCloud's dashboard in Cloud Virtual Machine and Cloud Block Storage. Or via API which needs slightly effort.

      To get storageIds values from API. Execute qcloudcli cbs DescribeCbsStorages then look at field storageId for each item. Select ones you want then put it into index.js file.

    • (optional) kMaxSnapshots -> define number of snapshots to be hold before deletion oldest one if a new snapshot needs to be created

    • (optional) kWaitBeforeCreation -> time wait in millisecond just before CreateSnapshot operation will be cariied out, just for safety for consecutive snapshot creation

  3. Execute npm install to install all dependencies.

  4. Execute node index.js to run the program thus begin backing up process.

  5. (optional) Recommend to automate it with cron job.

License

MIT, Wasin Thonkaew

qcloudbackup's People

Contributors

haxpor avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.