Skip to content

Commit

Permalink
Merge pull request #17 from Guiorgy/trailing-spaces
Browse files Browse the repository at this point in the history
trimmed trailing spaces
  • Loading branch information
BretFisher authored Oct 25, 2024
2 parents f12728a + bf6f5f7 commit 82290fa
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions vackup
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ cat <<EOF
export/import copies files between a host tarball and a volume. For making
volume backups and restores.
save/load copies files between an image and a volume. For when you want to use
save/load copies files between an image and a volume. For when you want to use
image registries as a way to push/pull volume data.
Usage:
Usage:
vackup export VOLUME FILE
Creates a gzip'ed tarball in current directory from a volume
Expand All @@ -51,13 +51,13 @@ fi
cmd_export() {
VOLUME_NAME="$2"
FILE_NAME="$3"

if [ -z "$VOLUME_NAME" ] || [ -z "$FILE_NAME" ]; then
echo "Error: Not enough arguments"
usage
exit 1
fi

if ! docker volume inspect --format '{{.Name}}' "$VOLUME_NAME";
then
echo "Error: Volume $VOLUME_NAME does not exist"
Expand Down Expand Up @@ -85,13 +85,13 @@ cmd_export() {
cmd_import() {
FILE_NAME="$2"
VOLUME_NAME="$3"

if [ -z "$VOLUME_NAME" ] || [ -z "$FILE_NAME" ]; then
echo "Error: Not enough arguments"
usage
exit 1
fi

if ! docker volume inspect --format '{{.Name}}' "$VOLUME_NAME";
then
echo "Error: Volume $VOLUME_NAME does not exist"
Expand All @@ -101,13 +101,13 @@ cmd_import() {
# TODO: check if file exists on host, if it does
# create a option for overwrite and check if that's set
# TODO: if FILE_NAME starts with / we need to error out
# unless we can translate full file paths
# unless we can translate full file paths

if ! docker run --rm \
-v "$VOLUME_NAME":/vackup-volume \
-v "$(pwd)":/vackup \
busybox \
tar -xvzf /vackup/"$FILE_NAME" -C /;
tar -xvzf /vackup/"$FILE_NAME" -C /;
then
echo "Error: Failed to start busybox container"
exit 1
Expand All @@ -126,7 +126,7 @@ cmd_save() {
exit 1
fi

if ! docker volume inspect --format '{{.Name}}' "$VOLUME_NAME";
if ! docker volume inspect --format '{{.Name}}' "$VOLUME_NAME";
then
echo "Error: Volume $VOLUME_NAME does not exist"
exit 1
Expand All @@ -146,30 +146,30 @@ cmd_save() {
docker commit -m "saving volume $VOLUME_NAME to /volume-data" "$CONTAINER_ID" "$IMAGE_NAME"

docker container rm "$CONTAINER_ID"

echo "Successfully copied volume $VOLUME_NAME into image $IMAGE_NAME, under /volume-data"
}

cmd_load() {
IMAGE_NAME="$2"
VOLUME_NAME="$3"

if [ -z "$VOLUME_NAME" ] || [ -z "$IMAGE_NAME" ]; then
echo "Error: Not enough arguments"
usage
exit 1
fi

if ! docker volume inspect --format '{{.Name}}' "$VOLUME_NAME";
if ! docker volume inspect --format '{{.Name}}' "$VOLUME_NAME";
then
echo "Volume $VOLUME_NAME does not exist, creating..."
docker volume create "$VOLUME_NAME"
fi

if ! docker run --rm \
-v "$VOLUME_NAME":/mount-volume \
"$IMAGE_NAME" \
cp -Rp /volume-data/. /mount-volume/;
cp -Rp /volume-data/. /mount-volume/;
then
echo "Error: Failed to start container from $IMAGE_NAME"
exit 1
Expand Down

0 comments on commit 82290fa

Please sign in to comment.