Compare commits
No commits in common. "528b0ee77ff3cf4a7abceee375dada630674d624" and "8c02e4f2317ca6053859cb95f74345d9bddaf01f" have entirely different histories.
528b0ee77f
...
8c02e4f231
|
@ -1,49 +0,0 @@
|
||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
[ $# -lt 2 ] && { echo "Usage: $0 {backup|restore} BACKUP_FILENAME"; exit 1; }
|
|
||||||
|
|
||||||
backup_file=$2
|
|
||||||
|
|
||||||
project_subscriber_volume_name=client_data
|
|
||||||
project_tor_volume_name=tor_config
|
|
||||||
tor_service=tor
|
|
||||||
|
|
||||||
docker-compose --log-level WARNING up --no-start
|
|
||||||
|
|
||||||
project_name=$(docker ps -a --no-trunc | grep $(docker-compose ps -q ${tor_service}) | awk '{ print $2; }' | awk -F "_" '{ print $1; }')
|
|
||||||
|
|
||||||
project_volumes=$(docker volume ls -f name=$project_name | awk '{if (NR > 1) print $2"\n";}')
|
|
||||||
|
|
||||||
subscriber_volume=$(echo "$project_volumes" | grep ${project_subscriber_volume_name} | xargs)
|
|
||||||
tor_volume=$(echo "$project_volumes" | grep ${project_tor_volume_name} | xargs)
|
|
||||||
|
|
||||||
function backup {
|
|
||||||
|
|
||||||
docker run --rm \
|
|
||||||
-v $subscriber_volume:/data/subscriber \
|
|
||||||
-v $tor_volume:/data/tor \
|
|
||||||
-v $(pwd):/backup \
|
|
||||||
ubuntu \
|
|
||||||
tar -C / -czvf /backup/$backup_file data
|
|
||||||
|
|
||||||
docker run --rm \
|
|
||||||
-v $(pwd):/backup \
|
|
||||||
ubuntu \
|
|
||||||
chown $UID:$UID /backup/$backup_file
|
|
||||||
}
|
|
||||||
|
|
||||||
function restore {
|
|
||||||
|
|
||||||
docker-compose stop $tor_service
|
|
||||||
|
|
||||||
docker run --rm \
|
|
||||||
-v $subscriber_volume:/data/subscriber \
|
|
||||||
-v $tor_volume:/data/tor \
|
|
||||||
-v $(pwd)/$backup_file:/backup/backup.tar.gz \
|
|
||||||
ubuntu \
|
|
||||||
tar -C / -xzvf /backup/backup.tar.gz
|
|
||||||
|
|
||||||
docker-compose start $tor_service
|
|
||||||
}
|
|
||||||
|
|
||||||
$1
|
|
25
scripts/tor-vol-migration.sh
Executable file
25
scripts/tor-vol-migration.sh
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Script to migrate from volume-less tor instance to one that retains
|
||||||
|
# tor hidden service state (onion url, etc.)
|
||||||
|
|
||||||
|
mkdir -p backup/tor
|
||||||
|
docker cp torch-subscriber-docker_tor_1:/var/lib/tor/svc backup/tor/
|
||||||
|
|
||||||
|
docker-compose down
|
||||||
|
docker-compose up --no-start
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
-v $(pwd)/backup/tor:/backup \
|
||||||
|
-v torch-subscriber-docker_tor_config:/tor \
|
||||||
|
ubuntu \
|
||||||
|
cp -r /backup/svc /tor/
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
-v torch-subscriber-docker_tor_config:/tor \
|
||||||
|
ubuntu \
|
||||||
|
chown -R 0:0 /tor
|
||||||
|
|
||||||
|
rm -rf backup
|
||||||
|
|
||||||
|
docker-compose up -d
|
Loading…
Reference in New Issue
Block a user