-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bec62b4
commit 2fd26cf
Showing
19 changed files
with
975 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## | ||
# | ||
# This project is developed and maintained by Indigen-Solution | ||
# Website: http://www.indigen.com | ||
# Contact: [email protected] | ||
# | ||
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Indigen-Solution | ||
See the AUTHORS file for details. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
DESTDIR= | ||
INSTALL_DIR=$(DESTDIR)/usr | ||
BUILD_DIR=./build | ||
NAME=indi-backup | ||
LIB_DIR=./lib | ||
|
||
all: | ||
mkdir -p $(BUILD_DIR) | ||
sed -s 's/@@VERSION@@/$(shell git describe --tags --long)/' $(NAME) > $(BUILD_DIR)/$(NAME) | ||
|
||
install: all | ||
mkdir -p $(INSTALL_DIR)/bin | ||
mkdir -p $(INSTALL_DIR)/lib/$(NAME) | ||
cp $(BUILD_DIR)/$(NAME) $(INSTALL_DIR)/bin | ||
chmod 755 $(INSTALL_DIR)/$(NAME) | ||
|
||
cp -r $(LIB_DIR) $(INSTALL_DIR)/lib/$(NAME) | ||
|
||
uninstall: | ||
rm -rf $(INSTALL_DIR)/bin/$(NAME) | ||
rm -rf $(INSTALL_DIR)/lib/$(NAME) | ||
|
||
clean: | ||
rm -rf $(BUILD_DIR) | ||
|
||
.PHONY: all install uninstall clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
# indi-backup | ||
|
||
A modular backup system write in bash with minimal dependency. | ||
A modular backup system write in bash with minimal dependencies. | ||
|
||
### Installation | ||
|
||
#### Debian / Ubuntu | ||
TODO | ||
|
||
#### Other linux distributions | ||
``` | ||
git clone https://github.com/indigen-solutions/indi-backup.git | ||
cd indi-backup | ||
make | ||
sudo make install | ||
``` | ||
|
||
|
||
### Documentation | ||
|
||
Full documentation available [here](https://github.com/indigen-solutions/indi-backup/wiki). | ||
Full documentation is available [here](https://github.com/indigen-solutions/indi-backup/wiki). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
################################################################################ | ||
# This file is a exemple of possible backup config for indi-backup | ||
# It register a task "data" that create a tarball of /home and | ||
# drop it in /backup | ||
################################################################################ | ||
|
||
IB_TASKS="data" # Declare all available tasks | ||
IB_STORAGES="disk" # Declare all available storages | ||
|
||
# Declare the "data" backup task | ||
IB_TASK_data_TYPE="tarball" # The task is of type "tarball" | ||
IB_TASK_data_FOLDER="/home" # List of folder that will be included in the tarball | ||
IB_TASK_data_STORAGE="disk" # The name of the storage you want to use for this task | ||
|
||
# Declare the "disk" storage method | ||
IB_STORAGE_disk_TYPE="fs" # The storage is of type "fs" | ||
IB_STORAGE_disk_BASEPATH="/backup" # The file will be stored under /backup directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
################################################################################ | ||
# This file is a exemple of possible backup config for indi-backup | ||
# It register a task "web" that create an incremental tarball of /var/www, | ||
# a task mysql that backup the mysql server and a task all that excute web and | ||
# mysql. All the bakup are sent to a remote ssh server. | ||
################################################################################ | ||
|
||
IB_TASKS="all web mysql" | ||
IB_STORAGES="sshBackup" | ||
|
||
# Declare the web task | ||
IB_TASK_web_TYPE="tarball-incremental" | ||
IB_TASK_web_FOLDERS="/var/www" | ||
IB_TASK_web_LIST_NAME="/root/backup-web.list" | ||
IB_TASK_web_FILE_BASENAME="webdata" | ||
IB_TASK_web_MASTER_FREQUENCY="weekly" | ||
IB_TASK_web_MASTER_FREQUENCY_VALUE="1" | ||
IB_TASK_web_STORAGE="sshBackup" | ||
|
||
# Declare the mysql task | ||
IB_TASK_mysql_TYPE="mysql" | ||
IB_TASK_mysql_USER="root" | ||
IB_TASK_mysql_PASSWORD="password" | ||
IB_TASK_mysql_DATABASES="my-database" | ||
IB_TASK_mysql_STORAGE="sshBackup" | ||
|
||
# Declare the all task | ||
IB_TASK_all_TYPE="subtask" | ||
IB_TASK_all_SUBTASKS="web mysql" | ||
|
||
# Declare the "ssh-backup" storage | ||
IB_STORAGE_sshBackup_TYPE="ssh" | ||
IB_STORAGE_sshBackup_HOST="backup.exemple.com" | ||
IB_STORAGE_sshBackup_USER="user" | ||
IB_STORAGE_sshBackup_BASEPATH="/backup" | ||
IB_STORAGE_sshBackup_SSHKEY="/root/.ssh/id_rsa" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
#!/bin/bash | ||
################################################################################ | ||
# | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2015 Indigen-Solution | ||
# See the AUTHORS file for details. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
################################################################################ | ||
|
||
################################################################################ | ||
# This is the main indi-backup script | ||
################################################################################ | ||
|
||
# | ||
# Load libraries | ||
# | ||
|
||
IB_LIB_DIR="/usr/lib/indi-backup" | ||
|
||
if [ ! -z $IB_DEVEL ] | ||
then | ||
IB_LIB_DIR="./lib" | ||
fi | ||
|
||
source $IB_LIB_DIR/utils.sh | ||
|
||
source $IB_LIB_DIR/task.sh | ||
source $IB_LIB_DIR/tasks/docker-mysql-dumper.sh | ||
source $IB_LIB_DIR/tasks/mysql.sh | ||
source $IB_LIB_DIR/tasks/subtask.sh | ||
source $IB_LIB_DIR/tasks/tarball.sh | ||
source $IB_LIB_DIR/tasks/tarball-incremental.sh | ||
|
||
source $IB_LIB_DIR/storage.sh | ||
source $IB_LIB_DIR/storages/fs.sh | ||
source $IB_LIB_DIR/storages/ssh.sh | ||
source $IB_LIB_DIR/storages/swift.sh | ||
|
||
|
||
# | ||
# Set default variables | ||
# | ||
VERSION="@@VERSION@@" | ||
CONFIG_FILE="/etc/indi-backup.conf" | ||
TASKS="" | ||
DATE=$(date --utc "+%Y%m%dT%H%M%SZ") | ||
|
||
IB_OPTIONS_LIST_TASKS="" | ||
IB_OPTIONS_LIST_STORAGES="" | ||
|
||
# | ||
# Parse command line arguments | ||
# | ||
while [[ $# > 0 ]] | ||
do | ||
key="$1" | ||
case $key in | ||
-c|--config) | ||
CONFIG_FILE="$2" | ||
shift | ||
;; | ||
--list-tasks) | ||
IB_OPTIONS_LIST_TASKS=1 | ||
;; | ||
--list-storages) | ||
IB_OPTIONS_LIST_STORAGES=1 | ||
;; | ||
-h|--help) | ||
ib_print_usage | ||
exit 0 | ||
;; | ||
--version) | ||
echo "Version: $VERSION" | ||
exit 0 | ||
;; | ||
-*) | ||
echo "Unknow options $1" | ||
exit -1 | ||
;; | ||
*) | ||
TASKS="$TASKS $1" | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
# | ||
# Include config file and do some check | ||
# | ||
if [[ (! -f $CONFIG_FILE) || (! -r $CONFIG_FILE) ]] | ||
then | ||
echo "No valid config file found [$CONFIG_FILE]"; | ||
exit -1; | ||
fi | ||
|
||
source $CONFIG_FILE | ||
|
||
if [ -z "$IB_TASKS" ] | ||
then | ||
echo "Invalid IB_TASKS in config file" | ||
exit -1; | ||
fi | ||
|
||
if [ -z "$IB_STORAGES" ] | ||
then | ||
echo "Invalid IB_STORAGES in config file" | ||
exit -1; | ||
fi | ||
|
||
# | ||
# Run options | ||
# | ||
if [ ! -z "$IB_OPTIONS_LIST_TASKS" ] | ||
then | ||
ib_task_list | ||
fi | ||
|
||
if [ ! -z "$IB_OPTIONS_LIST_STORAGES" ] | ||
then | ||
ib_storage_list | ||
fi | ||
|
||
# | ||
# Run task | ||
# | ||
for task in $TASKS | ||
do | ||
ib_task_run $task; | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
################################################################################ | ||
# | ||
# The MIT License (MIT) | ||
# | ||
# Copyright (c) 2015 Indigen-Solution | ||
# See the AUTHORS file for details. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
################################################################################ | ||
|
||
## | ||
# This method execute a storage stream | ||
# @param storageName The name of the storage stream to execute | ||
# @param taskName The name of the task to execute | ||
# @param itemName The name of the item you want to store | ||
## | ||
function ib_storage_run () { | ||
local storageName="$1" | ||
local taskName="$2" | ||
local itemName="$3" | ||
|
||
for storage in $IB_STORAGES | ||
do | ||
if [[ "$storage" == "$storageName" ]] | ||
then | ||
local storageType=$(ib_get_conf_value "IB_STORAGE_${storageName}_TYPE") | ||
case "$storageType" in | ||
swift) | ||
ib_storage_swift_run "$storageName" "$taskName" "$itemName" || return -1 | ||
;; | ||
fs) | ||
ib_storage_fs_run "$storageName" "$taskName" "$itemName" || return -1 | ||
;; | ||
ssh) | ||
ib_storage_ssh_run "$storageName" "$taskName" "$itemName" || return -1 | ||
;; | ||
*) | ||
echo "Unknow storage type [$storageType]" | ||
return -1 | ||
;; | ||
esac | ||
return 0 | ||
fi | ||
done | ||
echo "No storage [$storageName] found" | ||
} | ||
|
||
## | ||
# This method list all the registered storage in the configuration file. | ||
## | ||
function ib_storage_list() { | ||
for storageName in $IB_STORAGES | ||
do | ||
local type=$(ib_get_conf_value "IB_STORAGE_${storageName}_TYPE") | ||
echo " * ${storageName}" | ||
echo " - Type: ${type}" | ||
done | ||
} |
Oops, something went wrong.