From 0cddb5769659944fe08af1844c6860a802141804 Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Mon, 22 Jul 2024 16:21:29 +0530 Subject: [PATCH 1/7] chore: Data restore script added --- deploy/selfhost/restore.sh | 94 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100755 deploy/selfhost/restore.sh diff --git a/deploy/selfhost/restore.sh b/deploy/selfhost/restore.sh new file mode 100755 index 00000000000..08e0a049c27 --- /dev/null +++ b/deploy/selfhost/restore.sh @@ -0,0 +1,94 @@ +#!/bin/bash + +function print_header() { +clear + +cat <<"EOF" +-------------------------------------------- + ____ _ ///////// +| _ \| | __ _ _ __ ___ ///////// +| |_) | |/ _` | '_ \ / _ \ ///// ///// +| __/| | (_| | | | | __/ ///// ///// +|_| |_|\__,_|_| |_|\___| //// + //// +-------------------------------------------- +Project management tool from the future +-------------------------------------------- +EOF +} + +function restoreSingleVolume() { + selectedVolume=$1 + backupFolder=$2 + restoreFile=$3 + + docker volume rm "$selectedVolume" > /dev/null 2>&1 + docker volume create "$selectedVolume" > /dev/null 2>&1 + + docker run --rm \ + -e TAR_NAME="$restoreFile" \ + -v "$selectedVolume":"/vol" \ + -v "$backupFolder":/backup \ + busybox sh -c 'mkdir -p /restore && tar -xzf "/backup/${TAR_NAME}.tar.gz" -C /restore && mv /restore/${TAR_NAME}/* /vol' +} + +function restoreData() { + print_header + local BACKUP_FOLDER=${1:-$PWD} + + local dockerServiceStatus=$($COMPOSE_CMD ls --filter name=plane-app --format=json | jq -r .[0].Status) + local dockerServicePrefix="running" + + if [[ $dockerServiceStatus == $dockerServicePrefix* ]]; then + echo "Plane App is running. Please STOP the Plane App before restoring data." + exit 1 + fi + + local volumes=$(docker volume ls -f "name=plane-app" --format "{{.Name}}" | grep -E "_pgdata|_redisdata|_uploads") + # Check if there are any matching volumes + if [ -z "$volumes" ]; then + echo ".....No volumes found starting with 'plane-app'" + exit 1 + fi + + for BACKUP_FILE in $BACKUP_FOLDER/*.tar.gz; do + if [ -e "$BACKUP_FILE" ]; then + + local restoreFileName=$(basename "$BACKUP_FILE") + restoreFileName="${restoreFileName%.tar.gz}" + + local restoreVolName="plane-app_${restoreFileName}" + echo "Found $BACKUP_FILE" + + local docVol=$(docker volume ls -f "name=$restoreVolName" --format "{{.Name}}" | grep -E "_pgdata|_redisdata|_uploads") + + if [ -z "$docVol" ]; then + echo "Skipping: No volume found with name $restoreVolName" + else + echo ".....Restoring $docVol" + restoreSingleVolume "$docVol" "$BACKUP_FOLDER" "$restoreFileName" + fi + else + echo "No .tar.gz files found in the current directory." + echo "" + echo "Please provide the path to the backup file." + echo "" + echo "Usage: ./restore.sh /path/to/backup" + exit 1 + fi + done + + echo "" + echo "Restore completed successfully." + echo "" +} + +# if docker-compose is installed +if command -v docker-compose &> /dev/null +then + COMPOSE_CMD="docker-compose" +else + COMPOSE_CMD="docker compose" +fi + +restoreData $@ \ No newline at end of file From 82acb887c8454de6f215ce5926b055a9959a676f Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Mon, 22 Jul 2024 16:36:24 +0530 Subject: [PATCH 2/7] readme updated --- deploy/selfhost/README.md | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/deploy/selfhost/README.md b/deploy/selfhost/README.md index bb8a574d8de..5c0b7c4a7cf 100644 --- a/deploy/selfhost/README.md +++ b/deploy/selfhost/README.md @@ -372,6 +372,55 @@ Backup completed successfully. Backup files are stored in /....../plane-app/back --- +### Restore Data + +When you want to restore the previously backed-up data, you need to follow the below instructions + +1. Make sure that Plane-CE is installed, started and then stopped. This is to make sure that the docker volumes were created. + +1. Download the restore script using below command. We suggest to download in the same folder as `setup.sh`. + + ```bash + curl -fsSL -o restore.sh https://raw.githubusercontent.com/makeplane/plane/master/deploy/selfhost/restore.sh + chmod +x restore.sh + ``` + +1. Execute the below command to restore your data + + ```bash + ./restore.sh + ``` + + As an example, for a backup folder as `/opt/plane-selfhost/plane-app/backup/20240722-0914` expect response as below + + ```bash + ./restore.sh /opt/plane-selfhost/plane-app/backup/20240722-0914 + -------------------------------------------- + ____ _ ///////// + | _ \| | __ _ _ __ ___ ///////// + | |_) | |/ _` | '_ \ / _ \ ///// ///// + | __/| | (_| | | | | __/ ///// ///// + |_| |_|\__,_|_| |_|\___| //// + //// + -------------------------------------------- + Project management tool from the future + -------------------------------------------- + Found /opt/plane-selfhost/plane-app/backup/20240722-0914/pgdata.tar.gz + .....Restoring plane-app_pgdata + Found /opt/plane-selfhost/plane-app/backup/20240722-0914/redisdata.tar.gz + .....Restoring plane-app_redisdata + mv: can't rename '/restore/redisdata/*': No such file or directory + Found /opt/plane-selfhost/plane-app/backup/20240722-0914/uploads.tar.gz + .....Restoring plane-app_uploads + + Restore completed successfully. + ``` + +1. Start the Plane instance using `./setup.sh start` + +--- + + ## Upgrading from v0.13.2 to v0.14.x From 0cb8e0f012dfa61409830925337ab01f103204a6 Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Tue, 23 Jul 2024 09:38:22 +0530 Subject: [PATCH 3/7] coderabbit suggestion implemented --- deploy/selfhost/README.md | 30 +++++++++++++++++----------- deploy/selfhost/restore.sh | 41 +++++++++++++++++++++++++++++++------- 2 files changed, 52 insertions(+), 19 deletions(-) diff --git a/deploy/selfhost/README.md b/deploy/selfhost/README.md index 5c0b7c4a7cf..d6a79f72de2 100644 --- a/deploy/selfhost/README.md +++ b/deploy/selfhost/README.md @@ -374,49 +374,55 @@ Backup completed successfully. Backup files are stored in /....../plane-app/back ### Restore Data -When you want to restore the previously backed-up data, you need to follow the below instructions +When you want to restore the previously backed-up data, follow the instructions below. -1. Make sure that Plane-CE is installed, started and then stopped. This is to make sure that the docker volumes were created. +1. Make sure that Plane-CE is installed, started, and then stopped. This ensures that the Docker volumes are created. -1. Download the restore script using below command. We suggest to download in the same folder as `setup.sh`. +1. Download the restore script using the command below. We suggest downloading it in the same folder as `setup.sh`. ```bash curl -fsSL -o restore.sh https://raw.githubusercontent.com/makeplane/plane/master/deploy/selfhost/restore.sh chmod +x restore.sh ``` -1. Execute the below command to restore your data +1. Execute the command below to restore your data. ```bash ./restore.sh ``` - As an example, for a backup folder as `/opt/plane-selfhost/plane-app/backup/20240722-0914` expect response as below + As an example, for a backup folder `/opt/plane-selfhost/plane-app/backup/20240722-0914`, expect the response below: ```bash ./restore.sh /opt/plane-selfhost/plane-app/backup/20240722-0914 -------------------------------------------- - ____ _ ///////// - | _ \| | __ _ _ __ ___ ///////// - | |_) | |/ _` | '_ \ / _ \ ///// ///// - | __/| | (_| | | | | __/ ///// ///// - |_| |_|\__,_|_| |_|\___| //// - //// + ____ _ ///////// + | _ \| | __ _ _ __ ___ ///////// + | |_) | |/ _` | '_ \ / _ \ ///// ///// + | __/| | (_| | | | | __/ ///// ///// + |_| |_|\__,_|_| |_|\___| //// + //// -------------------------------------------- Project management tool from the future -------------------------------------------- Found /opt/plane-selfhost/plane-app/backup/20240722-0914/pgdata.tar.gz .....Restoring plane-app_pgdata + .....Successfully restored volume plane-app_pgdata from pgdata + Found /opt/plane-selfhost/plane-app/backup/20240722-0914/redisdata.tar.gz .....Restoring plane-app_redisdata mv: can't rename '/restore/redisdata/*': No such file or directory + Error: Failed to restore volume plane-app_redisdata from redisdata.tar.gz + Found /opt/plane-selfhost/plane-app/backup/20240722-0914/uploads.tar.gz .....Restoring plane-app_uploads + .....Successfully restored volume plane-app_uploads from uploads + Restore completed successfully. ``` -1. Start the Plane instance using `./setup.sh start` +1. Start the Plane instance using `./setup.sh start`. --- diff --git a/deploy/selfhost/restore.sh b/deploy/selfhost/restore.sh index 08e0a049c27..ae81bc2a842 100755 --- a/deploy/selfhost/restore.sh +++ b/deploy/selfhost/restore.sh @@ -23,44 +23,71 @@ function restoreSingleVolume() { restoreFile=$3 docker volume rm "$selectedVolume" > /dev/null 2>&1 + + if [ $? -ne 0 ]; then + echo "Error: Failed to remove volume $selectedVolume" + echo "" + return 1 + fi + docker volume create "$selectedVolume" > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Error: Failed to create volume $selectedVolume" + echo "" + return 1 + fi docker run --rm \ -e TAR_NAME="$restoreFile" \ -v "$selectedVolume":"/vol" \ -v "$backupFolder":/backup \ busybox sh -c 'mkdir -p /restore && tar -xzf "/backup/${TAR_NAME}.tar.gz" -C /restore && mv /restore/${TAR_NAME}/* /vol' + + if [ $? -ne 0 ]; then + echo "Error: Failed to restore volume ${selectedVolume} from ${restoreFile}.tar.gz" + echo "" + return 1 + fi + echo ".....Successfully restored volume $selectedVolume from $restoreFile" + echo "" } function restoreData() { print_header local BACKUP_FOLDER=${1:-$PWD} - local dockerServiceStatus=$($COMPOSE_CMD ls --filter name=plane-app --format=json | jq -r .[0].Status) - local dockerServicePrefix="running" + local dockerServiceStatus + dockerServiceStatus=$($COMPOSE_CMD ls --filter name=plane-app --format=json | jq -r .[0].Status) + local dockerServicePrefix + dockerServicePrefix="running" if [[ $dockerServiceStatus == $dockerServicePrefix* ]]; then echo "Plane App is running. Please STOP the Plane App before restoring data." exit 1 fi - local volumes=$(docker volume ls -f "name=plane-app" --format "{{.Name}}" | grep -E "_pgdata|_redisdata|_uploads") + local volumes + volumes=$(docker volume ls -f "name=plane-app" --format "{{.Name}}" | grep -E "_pgdata|_redisdata|_uploads") # Check if there are any matching volumes if [ -z "$volumes" ]; then echo ".....No volumes found starting with 'plane-app'" exit 1 fi + for BACKUP_FILE in $BACKUP_FOLDER/*.tar.gz; do if [ -e "$BACKUP_FILE" ]; then - local restoreFileName=$(basename "$BACKUP_FILE") + local restoreFileName + restoreFileName=$(basename "$BACKUP_FILE") restoreFileName="${restoreFileName%.tar.gz}" - local restoreVolName="plane-app_${restoreFileName}" + local restoreVolName + restoreVolName="plane-app_${restoreFileName}" echo "Found $BACKUP_FILE" - local docVol=$(docker volume ls -f "name=$restoreVolName" --format "{{.Name}}" | grep -E "_pgdata|_redisdata|_uploads") + local docVol + docVol=$(docker volume ls -f "name=$restoreVolName" --format "{{.Name}}" | grep -E "_pgdata|_redisdata|_uploads") if [ -z "$docVol" ]; then echo "Skipping: No volume found with name $restoreVolName" @@ -91,4 +118,4 @@ else COMPOSE_CMD="docker compose" fi -restoreData $@ \ No newline at end of file +restoreData "$@" \ No newline at end of file From d1e60bb147594fd142164486cd06d1e699c3c815 Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Tue, 23 Jul 2024 09:57:20 +0530 Subject: [PATCH 4/7] updated messages and readme --- deploy/selfhost/README.md | 7 +++---- deploy/selfhost/restore.sh | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/deploy/selfhost/README.md b/deploy/selfhost/README.md index d6a79f72de2..49f4334ffc3 100644 --- a/deploy/selfhost/README.md +++ b/deploy/selfhost/README.md @@ -407,16 +407,15 @@ When you want to restore the previously backed-up data, follow the instructions -------------------------------------------- Found /opt/plane-selfhost/plane-app/backup/20240722-0914/pgdata.tar.gz .....Restoring plane-app_pgdata - .....Successfully restored volume plane-app_pgdata from pgdata + .....Successfully restored volume plane-app_pgdata from pgdata.tar.gz Found /opt/plane-selfhost/plane-app/backup/20240722-0914/redisdata.tar.gz .....Restoring plane-app_redisdata - mv: can't rename '/restore/redisdata/*': No such file or directory - Error: Failed to restore volume plane-app_redisdata from redisdata.tar.gz + .....Successfully restored volume plane-app_redisdata from redisdata.tar.gz Found /opt/plane-selfhost/plane-app/backup/20240722-0914/uploads.tar.gz .....Restoring plane-app_uploads - .....Successfully restored volume plane-app_uploads from uploads + .....Successfully restored volume plane-app_uploads from uploads.tar.gz Restore completed successfully. diff --git a/deploy/selfhost/restore.sh b/deploy/selfhost/restore.sh index ae81bc2a842..cd453b2a71f 100755 --- a/deploy/selfhost/restore.sh +++ b/deploy/selfhost/restore.sh @@ -48,7 +48,7 @@ function restoreSingleVolume() { echo "" return 1 fi - echo ".....Successfully restored volume $selectedVolume from $restoreFile" + echo ".....Successfully restored volume $selectedVolume from ${restoreFile}.tar.gz" echo "" } From 651d236b62f78dc716ea8adb517ca79111b9762a Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Tue, 23 Jul 2024 10:03:36 +0530 Subject: [PATCH 5/7] updated readme --- deploy/selfhost/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/selfhost/README.md b/deploy/selfhost/README.md index 49f4334ffc3..c913dc71751 100644 --- a/deploy/selfhost/README.md +++ b/deploy/selfhost/README.md @@ -388,7 +388,7 @@ When you want to restore the previously backed-up data, follow the instructions 1. Execute the command below to restore your data. ```bash - ./restore.sh + ./restore.sh ``` As an example, for a backup folder `/opt/plane-selfhost/plane-app/backup/20240722-0914`, expect the response below: From 5499ff374666981afcdffd6a42f66d104a4f9a15 Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Tue, 23 Jul 2024 10:06:02 +0530 Subject: [PATCH 6/7] updated readme --- deploy/selfhost/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/deploy/selfhost/README.md b/deploy/selfhost/README.md index c913dc71751..9e03e9686dc 100644 --- a/deploy/selfhost/README.md +++ b/deploy/selfhost/README.md @@ -394,7 +394,6 @@ When you want to restore the previously backed-up data, follow the instructions As an example, for a backup folder `/opt/plane-selfhost/plane-app/backup/20240722-0914`, expect the response below: ```bash - ./restore.sh /opt/plane-selfhost/plane-app/backup/20240722-0914 -------------------------------------------- ____ _ ///////// | _ \| | __ _ _ __ ___ ///////// From 6d600fa73a4ccc43febd0a83a01e0520f718ebaa Mon Sep 17 00:00:00 2001 From: Manish Gupta Date: Tue, 23 Jul 2024 10:15:02 +0530 Subject: [PATCH 7/7] self host readme fix --- deploy/selfhost/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deploy/selfhost/README.md b/deploy/selfhost/README.md index 9e03e9686dc..c44771882c7 100644 --- a/deploy/selfhost/README.md +++ b/deploy/selfhost/README.md @@ -424,9 +424,8 @@ When you want to restore the previously backed-up data, follow the instructions --- - - -## Upgrading from v0.13.2 to v0.14.x +
+

Upgrading from v0.13.2 to v0.14.x

This is one time activity for users who are upgrading from v0.13.2 to v0.14.0 @@ -498,3 +497,4 @@ In case the suffixes are wrong or the mentioned volumes are not found, you will In case of successful migration, it will be a silent exit without error. Now its time to restart v0.14.0 setup. +
\ No newline at end of file