Setting up a backup on B2 / DONE

https://www.backblaze.com/

  1. Create an account in the system https://www.backblaze.com/arrow-up-right

  2. Activate B2 cloud storage for this: Log in to your account -> My Settings -> Enabled Products -> [+] B2 Cloud Storage

  3. Create a basket where we will save:

  4. ПAfter that we need to create an App key that can only make a record without the ability to delete the already created backup unfortunately it can not be done through the panel so we created a scriptarrow-up-right that can create a secure key through API backblaze)

To do this we need to:

  1. Clone repo:

    cd /root/
    git clone https://gitlab.com/BoxExchanger-public/b2-backups.git
  2. Go to the project folder:

    cd b2-backups
  3. Install Packages:

    npm i
  4. Get Master KEY (must be changed after creation)

  5. Create a key:

    npm run new-key

    B2 application key ID: keyID obtained in the previous step B2 application key: applicationKey obtained in the previous step

    B2 buckets ID: Buckets -> Your bucket -> Bucket ID

  6. Copy the obtained keys to install them on our server. (temporarily save them in a text file)

  7. Recreate the key obtained at step 4.4 so that the old one is no longer available (it is no longer necessary to copy it)

  8. Installarrow-up-right rclone on the server.

  9. Install the obtained keys on the server using the following commands:

    rclone config

    Next, we will be asked to answer questions:

    e/n/d/r/c/s/q> n
    name> b2
    Storage> 5
    account> (App Key Id c шага 4.6)
    key> (App Key c шага 4.6)
  10. Configure backup.sh to properly create the backup and notify the administrator.

    cd /root/b2-backups
    nano backup.sh

    Configuring the block # -- Configuration --

    backup.sh
    # rclone remote name.
    RCLONE_REMOTE="b2"
    # b2 bucket name.
    B2_BUCKET="name-project"
    # Telegram Bot Token
    BOT_TOKEN="1234567890:ABCDEF1234567890ABCDEF1234567890ABC"
    # (list) of Telegram Chat IDs.
    # e.g: CHAT_IDS=("1234567890" "0987654321")
    CHAT_IDS=("1234567890")

8. Give permissions to run the bash-script file backup.sh

9. Check the work of the backup script

10. Set auto backup by crown (in the example every day at 4am server time usually GMT).

circle-info

Root privileges are required for the script to work. By default, the script looks for the API configuration in the folder /var/www/exchanger-api/config/app_config.json. If you have a different way fix it in the BOXEXCHANGER_API_PATH fily backup.sh in section # -- Init Default Vars -- It is mandatory to have a uri to mongodb in the configuration file

Last updated