Root check and docker image integration
This commit is contained in:
parent
55aac75163
commit
234fe510db
@ -25,6 +25,8 @@ target_host="127.0.0.1" # rsync target host
|
||||
target_user="backup" # rsync target user
|
||||
target_key='/home/xyz/.ssh/rsync' # rsync key
|
||||
#Docker
|
||||
docker_enabled=false # will you use docker backup
|
||||
docker_images=false # backup docker images
|
||||
#Docker volumes
|
||||
#Rsync
|
||||
#Daily cron
|
||||
|
30
main.sh
30
main.sh
@ -22,6 +22,11 @@ source "$config"
|
||||
|
||||
echo "Configuration file loaded" >&2
|
||||
|
||||
if [ "$EUID" -ne 0 ]
|
||||
then echo "Please run as root"
|
||||
exit
|
||||
fi
|
||||
|
||||
function makedir {
|
||||
timestamp=$(date +%Y%m%d_%H%M)
|
||||
mkdir /tmp/backify-$timestamp
|
||||
@ -97,16 +102,35 @@ function push {
|
||||
fi
|
||||
}
|
||||
|
||||
function dockerbackup {
|
||||
if [ "docker_enabled" = true] then
|
||||
if [ "docker_images" = true] then
|
||||
echo "Backing up Docker images..." >&2
|
||||
for i in `docker inspect --format='{{.Name}}' $(docker ps -q) | cut -f2 -d\/`
|
||||
do container_name=$i
|
||||
echo -n "$container_name - "
|
||||
container_image=`docker inspect --format='{{.Config.Image}}' $container_name`
|
||||
mkdir -p $tmpdir/containers/$container_name
|
||||
save_dir="$tmpdir/containers/$container_name/$container_name-image.tar"
|
||||
docker save -o $save_dir $container_image
|
||||
echo "Finished" >&2
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function runbackup {
|
||||
if [ "enabled" = true] then
|
||||
# step 1 : create directory
|
||||
makedir
|
||||
# step 2 : wwwbackup
|
||||
# step 2 : www backup
|
||||
wwwbackup
|
||||
# step 3 : vhostbackup
|
||||
# step 3 : vhost backup
|
||||
vhostbackup
|
||||
# step 4: logbackup
|
||||
# step 4: log backup
|
||||
logbackup
|
||||
# step 5: docker backup
|
||||
dockerbackup
|
||||
# archive data
|
||||
echo "Creating backup archive..." >&2
|
||||
tar -czvf /opt/backify-$timestamp.tar.gz $tmpdir
|
||||
|
Loading…
Reference in New Issue
Block a user