Compare commits

..

No commits in common. "223eff0d1bc700e712d6f598914b62b8f5efa7eb" and "89086a68d3d69bf03398d8b0a007cc621ba55221" have entirely different histories.

3 changed files with 64 additions and 76 deletions

View File

@ -1,49 +1,56 @@
Backify 🗃️ # Backify 🗃️
===========
A powerful and automated bash script for backing up all kinds of Linux data, archiving it and pushing it to a remote host. I don't know why are You here, but I wouldn't be in Your skin.
What is Backify? 👾
-------------------
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. ## What's this ? 👾
Backify is a shell script that helps You automate backup of all kind of data from Linux systems.
What makes it different ? Most of backup scripts are specialised for one kind of data backup, while here You get to pick what do You want saved, reaching from system logs all the way to containers.
It was tailored to personal needs since there was no complete solution for the specific use case.
Configuration 🧙‍♂️ ## How do I configure it ? 🧙‍♂️
------------------- All of the options are included in the backup.cfg file.
The script has an integrity check for the configuration, so no external command can be embedded into it by any kind of malware.
See the table below for configuration options
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: ## Configuration options 🪄
| Name | Value | Specifics |
| --- | --- | --- |
| Enabled | true/false | Disable the main function |
| 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 |
| 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 |
To-Do List
----------
- [ ] Rsync implementation via shell |Name |Value |Specifics |
- [ ] Rsync implementation via Docker |----------------|-------------------------------|-----------------------------|
- [ ] Cron scheduler |Enabled |true/false |Disable the main function |
- [ ] RHEL/Ubuntu parser |www_backup |true/false |Backup of webroot directory |
- [ ] Automatic adjustments per system |www_dir |------> |Path to webroot |
- [ ] MySQL backups |vhost_backup |true/false |Backup of vhost configuration|
- [ ] PostgreSQL backups |vhost_dir |------> |Path to vhost files |
- [ ] Cover more system logs |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 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 |
|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 |
## ToooooooDoooooooo
- [ ] Rsync implementation via shell
- [ ] Rsync implementation via Docker
- [ ] Cron scheduler
- [ ] RHEL/Ubuntu parser
- [ ] Automatic adjustments per system
- [ ] MySQL backups
- [ ] PostgreSQL backups
- [ ] Cover more system logs

View File

@ -22,8 +22,3 @@ docker_enabled=false # will you use docker backup
docker_images=false # backup docker images docker_images=false # backup docker images
docker_volumes=false #backup docker volumes docker_volumes=false #backup docker volumes
docker_data=false #backup container information docker_data=false #backup container information
db_backup=false #backup databases
database_type=mysql #mysql or postgresql
db_username=user #database user
db_password=user #database password
db_name=user #name of the database

40
main.sh
View File

@ -6,11 +6,12 @@ echo "Backify is starting, looking for configuration file..." >&2
config='backup.cfg' config='backup.cfg'
config_secured='sbackup.cfg' config_secured='sbackup.cfg'
if [ ! -f "$config" ] if [ -f "$config" ]
then then
echo "Error: Config file not found: $config" >&2 echo "Configuration found." >&2
echo "Please create a config file or specify the location of an existing file." >&2 else
exit 1 echo "Configuration not found" >&2
exit
fi fi
if grep -E -q -v '^#|^[^ ]*=[^;]*' "$config"; then if grep -E -q -v '^#|^[^ ]*=[^;]*' "$config"; then
@ -31,18 +32,15 @@ fi
function system { function system {
if [ -f /etc/redhat-release ] if [ -f /etc/redhat-release ]
then then
echo "Discovered Red Hat-based OS..."
system='rhel' system='rhel'
elif [ -f /etc/lsb-release ] fi
then
echo "Discovered Ubuntu-based OS..." if [ -f /etc/lsb-release ]
then
system='ubuntu' system='ubuntu'
else fi
echo "Error: Unable to detect OS type."
exit 1
fi
echo "Discovered $system based OS..." >&2 echo "Discovered $system based OS..." >&2
} }
@ -233,18 +231,6 @@ function dockerbackup {
fi fi
} }
function backup_db {
if [ "$db_backup" = true ]
then
echo "Backing up database..." >&2
mkdir -p $tmpdir/db
if [ "$database_type" = "mysql" ]
then
mysqldump -u "$db_username" -p"$db_password" "$db_name" > $tmpdir/db/db.sql
elif [ "$database_type" = "postgresql" ]
echo "soon"
}
function runbackup { function runbackup {
# init, config check # init, config check
init init