Ru-b2-SQL-Backups/README.md

69 lines
3.2 KiB
Markdown
Raw Permalink Normal View History

2023-02-28 11:10:00 -07:00
# Ru(b2)sql Backups
2023-02-23 17:53:55 -07:00
This Ruby program is designed to perform regular backups of a MySQL database to a local directory, and optionally to a Backblaze B2 cloud storage bucket.
Please put any feature suggestions into [Issues](https://github.com/PixelRidge-Softworks/Ru-b2-SQL-Backups/issues) and we will implement them if we can!
2023-05-03 14:12:58 -06:00
If you'd like to help with the development of Ru(b2)SQL Backups, you can clone this repository and then create a Pull Request. If we don't find any issues, we will merge the PR.
2023-10-26 19:00:49 -06:00
If you'd like to support PixelRidge Softworks OpenSource Development, check out our [Patreon](https://patreon.com/PixelRidgeSoftworksOSP)
2024-02-28 21:16:16 -07:00
If you need more direct help, join our [Discord](https://discord.pixelridgesoftworks.com)
2023-02-23 17:53:55 -07:00
## Installation
2023-03-19 18:21:44 -06:00
To use this program, you'll need to run the following: (this is fixed now!)
[Source](https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/src/branch/main/rub2/install.sh)
2023-02-23 17:53:55 -07:00
2023-03-19 17:35:20 -06:00
```bash
wget https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/src/branch/main/rub2/install.sh && bash ./install.sh
2023-02-23 17:53:55 -07:00
```
## Configuration
When you run the program for the first time, it will prompt you for configuration details. These include the following:
- MySQL host, username, and password
- Backup directory (optional, defaults to the current directory)
- Backblaze B2 credentials (optional, enables cloud storage backups)
## Usage
To run the program, simply execute the `starter.rb` file using the following command from inside the cloned directory:
2023-03-19 17:35:20 -06:00
```bash
2023-02-23 17:53:55 -07:00
ruby starter.rb
```
You can also run this program via Cron. For example, this Crontab would run the program every 6 hours:
2023-03-19 17:35:20 -06:00
```bash
0 */6 * * * /usr/bin/PixelatedStudios/Ruby/Ru-B2-SQL-Backups/starter.rb
2023-02-23 17:53:55 -07:00
```
2023-10-26 19:00:02 -06:00
For easier access, you can also add this to your system path:
```bash
/usr/bin/PixelRidge-Softworks/Ruby/Ru-B2-SQL-Backups/rub2
```
2023-02-23 17:53:55 -07:00
This will perform a backup of the MySQL database according to the configuration settings. If Backblaze B2 backups are enabled, the program will upload the backup file to the cloud storage bucket.
## Maintenance
To update the program, simply pull the latest changes from the Git repository and re-run `bundle install` to ensure that any new gems are installed.
If you need to change the configuration settings, simply delete the `config.json` file and run the program again to be prompted for new configuration details.
2023-05-03 14:18:15 -06:00
~~To delete old backups, the program will check for backups that are older than `local_retention_days` days (default 30) and delete them. To modify this time window, edit the `max_age_days` variable in the `delete_old_backups` method of the `MysqlDatabaseBackup` class.~~
2023-10-26 19:00:02 -06:00
2023-05-03 14:18:15 -06:00
^^ This is no longer applicable, you can now set the retention time in the config.json
2023-02-23 17:53:55 -07:00
## Compatibility
2023-10-26 19:00:02 -06:00
This program is compatible with Debian and RHEL based systems, but could be made to work with any systems compatible with Ruby, Python3, and Bash.
2023-05-03 14:12:58 -06:00
2023-05-03 15:42:14 -06:00
This program was also built on Arch Linux, so it should also run fine on Manjaro, Arch, and any other Arch based distro.
2023-02-23 17:53:55 -07:00
## Backblaze B2
2023-03-19 17:35:20 -06:00
Optionally, this program can update (and maintain) your Backblaze B2 bucket. It does this by removing the previous backups from the B2 bucket on a configurable timer