40 lines
565 B
Bash
40 lines
565 B
Bash
|
#!/bin/ash
|
||
|
|
||
|
sleep 5
|
||
|
|
||
|
# Ask for restore file name.
|
||
|
if [[ $(echo $(find /mnt/backups -type f -maxdepth 1 | wc -l)) -eq 0 ]]; then
|
||
|
echo "There is no backup."
|
||
|
exit
|
||
|
fi
|
||
|
|
||
|
echo "The following backups are available."
|
||
|
ls /mnt/backups
|
||
|
echo
|
||
|
echo "Enter the backup file name to be restored."
|
||
|
echo -n "-> "
|
||
|
read TMP_SELECT
|
||
|
|
||
|
TMP_TARGET=/mnt/backups/$TMP_SELECT
|
||
|
|
||
|
if [[ -f $TMP_TARGET ]]; then
|
||
|
echo $TMP_TARGET
|
||
|
else
|
||
|
echo "File not found."
|
||
|
exit
|
||
|
fi
|
||
|
|
||
|
#
|
||
|
# Restore
|
||
|
#
|
||
|
gzip -dk $TMP_TARGET
|
||
|
TMP_TAR=${TMP_TARGET%.*}
|
||
|
|
||
|
cd /tmp
|
||
|
tar -xvf $TMP_TAR
|
||
|
|
||
|
rm $TMP_TAR
|
||
|
|
||
|
# Finish.
|
||
|
echo "Restored."
|