Setting up a backup on B2 / DONE
https://www.backblaze.com/
Create an account in the system https://www.backblaze.com/
Activate B2 cloud storage for this: Log in to your account -> My Settings -> Enabled Products -> [+] B2 Cloud Storage
Create a basket where we will save:
П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 script that can create a secure key through API backblaze)
To do this we need to:
Clone repo:
cd /root/ git clone https://gitlab.com/BoxExchanger-public/b2-backups.git
Go to the project folder:
cd b2-backups
Install Packages:
npm i
Get Master KEY (must be changed after creation)
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
Copy the obtained keys to install them on our server. (temporarily save them in a text file)
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)
Install rclone on the server.
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)
Configure backup.sh to properly create the backup and notify the administrator.
cd /root/b2-backups nano backup.sh
Configuring the block
# -- Configuration --
# 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")
Configuration Descriptions: \
**RCLONE\_REMOTE**: The name of the rclone configuration. This was specified in step 6 as name, for example, b2.
**B2\_BUCKET**: The name of the bucket in BackBlaze, which was set in step 3.
**BOT\_TOKEN**: The token for your Telegram bot, obtained from @BotFather. Make sure to start the bot by sending the /start command.
**CHAT\_IDS**: The Telegram IDs of the clients who should receive notifications about backup statuses. You can get your Telegram ID by using the bot @myidbot.
8. Give permissions to run the bash-script file backup.sh
```bash
chmod +x backup.sh
```
 If the script did the job correctly the last line will be:\
`Backup completed successfully.`\
You should also receive a message in .telegram: \
`📦 Backup on`` `_`hostname`_` ``completed successfully.`
9. Check the work of the backup script
```bash
./root/b2-backups/backup.sh
```
10. Set auto backup by crown (in the example every day at 4am server time usually GMT).
```bash
(crontab -l; echo "0 */4 * * * bash /root/b2-backups/backup.sh >> /tmp/bk.log 2>&1") | crontab -
```
Last updated