From eb42729b5aa3da6b425a3ccfe581fa9dcc7fa46e Mon Sep 17 00:00:00 2001 From: Evan <71018479+Evan-aja@users.noreply.github.com> Date: Thu, 5 May 2022 00:26:25 +0700 Subject: Migration script from Ferdi to Ferdium for Linux & MacOS (#91) [skip ci] Co-authored-by: Vijay A --- scripts/migration/migrate-unix.sh | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 scripts/migration/migrate-unix.sh (limited to 'scripts') diff --git a/scripts/migration/migrate-unix.sh b/scripts/migration/migrate-unix.sh new file mode 100755 index 000000000..529716d85 --- /dev/null +++ b/scripts/migration/migrate-unix.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +set -e + +echo "********************************************" +echo " Ferdium User Data Migration Tool " +echo " WARNING: UNIX OS Only! " +echo "********************************************" +echo "This tool migrates your user data from Ferdi to Ferdium." +echo "Intended to be used on Linux or MacOS machine." +read -p "Do you want to proceed? (y/N) " confirm + +case "$confirm" in + y|Y|[yY][eE][sS] ) echo "Starting...";; + n|N|[nN][oO] ) exit 1;; + * ) exit 1;; +esac + +os_check=$(uname) + +if [ $os_check == "Linux" ]; then + echo "Your OS is: Linux" + BASE_PATH="$HOME/.config" +elif [ $os_check == "Darwin" ]; then + echo "Your OS is: MacOS" + BASE_PATH="$HOME/Library/Application Support" +else + echo "Your OS is not supported by this script" + exit 1 +fi + +FERDI_PATH="$BASE_PATH/Ferdi" +FERDIUM_PATH="$BASE_PATH/Ferdium2" + +if [ -d "$FERDIUM_PATH" ]; then + echo "Path $FERDIUM_PATH exist, making a backup" + if ! mv -vf "$FERDIUM_PATH" "$FERDIUM_PATH.bak" 2> /dev/null ; then + read -p "A previous backup already exists at $FERDIUM_PATH.bak. do you want to remove it? (y/N) " confirm + echo + case "$confirm" in + y|Y|[yY][eE][sS] ) echo "Deleting...";; + n|N|[nN][oO] ) exit 1;; + * ) exit 1;; + esac + echo + rm -rf "$FERDIUM_PATH.bak" + mv -vf "$FERDIUM_PATH" "$FERDIUM_PATH.bak" + fi +fi + +if mv -vf "$FERDI_PATH" "$FERDIUM_PATH"; then + echo "Files exported succesfully" +else + echo "ERROR!" + echo "No user data was found to be exported. Exiting..." + exit 1 +fi + +if [ -f "$FERDIUM_PATH/server.sqlite" ]; then + echo "********************************************" + echo " Success! " + echo "********************************************" +else + echo "********************************************" + echo "WARNING: Your data was partially migrated!" + echo "It was detected that your account is using Ferdi servers to sync your data." + echo "Please, check this guide on how to export and import your data manually:" + echo "https://github.com/ferdium/ferdi/blob/main/MIGRATION.md" + echo "********************************************" +fi -- cgit v1.2.3-54-g00ecf