Skip to content

Commit

Permalink
Update syno_recover_data.sh
Browse files Browse the repository at this point in the history
v0.0.3-beta
- Minor improvements.
  • Loading branch information
007revad committed Apr 12, 2024
1 parent aacc490 commit 6cf6c43
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions syno_recover_data.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
#!/usr/bin/env bash
# shellcheck disable=SC2002
# https://kb.synology.com/en-id/DSM/tutorial/How_can_I_recover_data_from_my_DiskStation_using_a_PC
#---------------------------------------------------------------------------------------
# Recover data from Synology drives using a computer
#
# GitHub: https://github.com/007revad/Synology_Recover_Data
# Script verified at https://www.shellcheck.net/
#
# Run in Ubuntu terminal:
# sudo -i /home/ubuntu/syno_recover_data.sh
#
# https://kb.synology.com/en-global/DSM/tutorial/How_can_I_recover_data_from_my_DiskStation_using_a_PC
#---------------------------------------------------------------------------------------

#mount_path="/home/ubuntu/mount"
mount_path="/home/ubuntu"


scriptver="v0.0.3"
script=Synology_Recover_Data
#repo="007revad/Synology_Recover_Data"
#scriptname=syno_recover_data

# Show script version
#echo -e "$script $scriptver\ngithub.com/$repo\n"
echo -e "$script $scriptver\n"

# Shell Colors
#Black='\e[0;30m' # ${Black}
#Red='\e[0;31m' # ${Red}
Expand Down Expand Up @@ -52,20 +72,21 @@ while [[ ! -d $mount_path ]]; do
read -r mount_path
done


## Install mdadm, lvm2 and btrfs-progs
#echo -e "\nInstalling mdadm, lvm2 and btrfs-progs"
##apt-get update
##apt-get install -y mdadm lvm2 btrfs-progs

# Install mdadm (latest lvm2 and btrfs-progs included in Ubuntu 19.10 and later)
echo -e "\nInstalling mdadm"
apt-get update
apt-get install -y mdadm

# Install mdadm, lvm2 and btrfs-progs if missing
install_executable(){
# $1 is mdadm, lvm2 or btrfs-progs
if ! which "$1" >/dev/null; then
echo -e "\nInstalling $1"
apt-get update
apt-get install -y "$1"
fi
}
install_executable mdadm
install_executable lvm2
install_executable btrfs-progs

# Assemble all the drives removed from the Synology NAS
if which mdadm ; then
if which mdadm >/dev/null; then
echo -e "\nAssembling your Synology drives"
# mdadm options:
# -A --assemble Assemble a previously created array.
Expand All @@ -84,7 +105,6 @@ else
exit 1
fi


# Get device path(s)
if lvs | grep 'volume_' >/dev/null; then
# Classic RAID/SHR with multiple volume support
Expand Down Expand Up @@ -193,3 +213,4 @@ fi

exit


0 comments on commit 6cf6c43

Please sign in to comment.