rorenv/backup/restore.sh

40 lines
565 B
Bash
Raw Normal View History

2023-05-05 12:44:29 +09:00
#!/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."