Backify/README.MD

88 lines
3.5 KiB
Plaintext
Raw Normal View History

2023-02-12 13:43:52 +00:00
# Backify 🗃️
-------------------
2023-02-11 10:41:19 +00:00
2023-02-12 13:30:54 +00:00
2023-02-12 13:43:52 +00:00
## What is Backify? 👾
2023-02-11 10:41:19 +00:00
-------------------
2023-02-12 13:42:52 +00:00
Backify is a shell script that helps you automate the backup process of all kinds of data from Linux systems. It differs from other backup scripts because it gives you the flexibility to choose what you want to save, ranging from system logs to containers. The script was tailored to meet personal needs as there was no complete solution for the specific use case.
2023-02-12 13:30:54 +00:00
2023-02-12 13:43:52 +00:00
## Prerequisites 👷
2023-02-12 13:28:20 +00:00
-------------------
2023-02-12 13:42:52 +00:00
2023-02-12 13:28:20 +00:00
- The script must be executed as root.
- A configuration file named `backup.cfg` must exist in the same directory as the script.
- The system must be either a Red Hat-based or an Ubuntu-based distribution.
2023-02-12 13:30:54 +00:00
2023-02-12 13:43:52 +00:00
## Configuration 🧙‍♂️
2023-02-11 10:41:19 +00:00
-------------------
2023-02-12 13:42:52 +00:00
2023-02-11 10:41:19 +00:00
All configuration options can be found in the `backup.cfg` file. The script has an integrity check in place to ensure that no external commands can be embedded into it by malware. The following table provides an overview of the available configuration options:
| Name | Value | Specifics |
| --- | --- | --- |
2023-02-12 12:26:12 +00:00
| enabled | true/false | Disable the main function |
| backup_path | ------> | Set where to save the backup |
2023-02-11 10:41:19 +00:00
| www_backup | true/false | Backup of the webroot directory |
| www_dir | ------> | Path to the webroot |
| vhost_backup | true/false | Backup of the vhost configuration |
| vhost_dir | ------> | Path to the vhost files |
| log_backup | true/false | Backup log files |
| log_backup_web | true/false | Backup web app logs |
| apache | true/false | Enable Apache logs |
| nginx | true/false | Enable nginx logs |
| fail2ban_log | true/false | Enable fail2ban logs |
| log_purge | true/false | Truncate logs after backup |
| rsync_push | true/false | Push the backup file to a remote server |
| push_clean | true/false | Delete the backup file after push |
| target_host | ------> | Backup push target host |
| target_user | ------> | Backup push target username |
| target_key | ------> | Backup target ssh key |
2023-02-12 12:26:12 +00:00
| target_dir | ------> | Backup target push to location |
2023-02-11 10:41:19 +00:00
| docker_enable | true/false | Enable Docker backups |
| docker_images | true/false | Backup Docker images |
| docker_volumes | true/false | Backup Docker volumes |
| docker_data | true/false | Backup container information |
2023-02-11 10:58:21 +00:00
| db_backup | true/false | Backup database |
| database_type | mysql/postgresql | Database type |
| db_username | ------> | Username for DB access |
| db_password | ------> | Password for DB access |
| db_name | ------> | Name of database |
2023-02-12 13:42:52 +00:00
| db_all | ------> | Dump all databases instead of specific one |
2023-02-12 13:43:52 +00:00
## Script Execution 🪄
2023-02-12 13:42:52 +00:00
-------------------
To execute the script, simply run the following command in the terminal:
> ./backify.sh
The script will first initialize by checking for the existence of the configuration file, loading its parameters, and verifying that the script is being executed as root.
Then, it will determine whether the system is a Red Hat-based or an Ubuntu-based distribution.
Finally, the script will create a new directory with a timestamped name in the backup_path directory, where the backups will be stored.
The components specified in the configuration file will then be backed up to the newly created directory.
2023-02-12 13:43:52 +00:00
## Automation 🤖
2023-02-12 13:42:52 +00:00
-------------------
Here's an example of how you can use cron on Linux to run your script every day at 12 PM:
Open the terminal and type crontab -e to open the cron table for editing.
Add the following line to the end of the file:
> 0 12 * * * /path/to/your/script.sh
Save and exit the file.