-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvolumes_restore.sh
More file actions
executable file
·49 lines (39 loc) · 1.47 KB
/
volumes_restore.sh
File metadata and controls
executable file
·49 lines (39 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
START=$SECONDS
echo "Restore docker containers? (Existing data will be removed)."
read -p "Are you sure? (y/n) " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
# Use the commandline argument as the target directory (by default its ./ )
TARGETDIR=${1:-./}
# Make sure the targetdir has 1 slash at the end by removing any slash first, and then appending it
TARGETDIR=${TARGETDIR%/}
TARGETDIR=${TARGETDIR}/
echo "-> docker compose down"
docker compose down
# loop through each volume
for VOLUME in gitlab_config gitlab_logs gitlab_data gitlab_lfs
do
echo "-> restore volume $VOLUME"
docker run -i --rm --name="docker_volume_restore_$VOLUME" -v $VOLUME:/volume --log-driver none loomchild/volume-backup restore -f -c none < ${TARGETDIR}backup_$VOLUME.tar # -f = force, '-c none' = no compression
done
echo "-> docker compose up -d"
docker compose up -d
echo "-> docker ps --filter \"name=gitlab\""
docker ps --filter "name=gitlab"
# show how much time this took...
DURATION=$(( SECONDS - START ))
if (( $DURATION > 3600 )) ; then
let "hours=DURATION/3600"
let "minutes=(DURATION%3600)/60"
let "seconds=(DURATION%3600)%60"
echo "Completed in $hours hour(s), $minutes minute(s) and $seconds second(s)"
elif (( $DURATION > 60 )) ; then
let "minutes=(DURATION%3600)/60"
let "seconds=(DURATION%3600)%60"
echo "Completed in $minutes minute(s) and $seconds second(s)"
else
echo "Completed in $DURATION seconds"
fi
fi