mirror of
https://github.com/Sneed-Group/samback
synced 2024-10-30 08:07:53 +00:00
Add 'samback.sh'
This commit is contained in:
parent
a0a7f4c6e9
commit
3f9a7996fb
1 changed files with 33 additions and 0 deletions
33
samback.sh
Normal file
33
samback.sh
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Neat splash.
|
||||||
|
echo ""
|
||||||
|
echo " mmmm mmmmm m "
|
||||||
|
echo " mm mmm mmm m m mmm mmm m m "
|
||||||
|
echo " mmmmm m m m m m mmmmm m m m m m mm "
|
||||||
|
echo " mm mmmmm m m m m m mmmmm m mmm "
|
||||||
|
echo " mmmmm m m m m mmmmmm m mmmm m mm "
|
||||||
|
echo " THE Simple Cloning Automated Tool, MAN!"
|
||||||
|
echo " Version 2.2024a"
|
||||||
|
|
||||||
|
# Get the currently booted HDD
|
||||||
|
root_device=$(df / | grep -Eo '^/dev/[^[:space:]]+')
|
||||||
|
|
||||||
|
# Extract the HDD from the root device
|
||||||
|
booted_hdd=$(echo "$root_device" | sed 's/[0-9]*$//' | sed 's/\/dev\///g')
|
||||||
|
|
||||||
|
# Find first other connected HDD of same size
|
||||||
|
other_hdd=$(lsblk -o NAME,SIZE -d | grep "$(lsblk -o SIZE -n /dev/$booted_hdd | head -n 1)"| grep -v "$booted_hdd" | awk '{print $1}' | head -n 1)
|
||||||
|
|
||||||
|
echo "<SAMBACK> [MSG]: Currently booted HDD (from): $booted_hdd"
|
||||||
|
echo "<SAMBACK> [MSG]: Same size HDD that is NOT the currently booted device (to): $other_hdd"
|
||||||
|
|
||||||
|
if [ ! "$other_hdd" == "" ]; then
|
||||||
|
|
||||||
|
# Here we clone our boot drive to our other drive
|
||||||
|
echo "<SAMBACK> [MSG]: Cloning booted /dev/$booted_hdd to /dev/$other_hdd... (This may take awhile, will run in background)"
|
||||||
|
sudo nohup dd if=/dev/$booted_hdd of=/dev/$other_hdd bs=4M status=progress > /dev/null 2>&1 &
|
||||||
|
else
|
||||||
|
echo "<SAMBACK> [ERR]: No drive of same size as boot device found!"
|
||||||
|
exit 1
|
||||||
|
fi
|
Loading…
Reference in a new issue