~crc_/retro-ilo

508a27d53eb5d770dc35070047602a948c971866 — crc 1 year, 1 month ago 63a155f
konilo.sh now has backup/restore functionality

FossilOrigin-Name: 5c2eb52783f168a3e6b1af4516626a9015eeca7c0e8fbe8e3201ec0bcb730e1d
1 files changed, 60 insertions(+), 0 deletions(-)

M konilo.sh
M konilo.sh => konilo.sh +60 -0
@@ 232,6 232,51 @@ if [ "$1" = "uninstall" ]; then
  exit
fi

# --------------------------------------------------------------
# Backup
# --------------------------------------------------------------

if [ "$1" = "backup" ]; then
  cd ~/.konilo || exit
  D=$(date '+%Y%m%d-%H%M')
  tar cf $D.tar ilo.rom ilo.blocks
  gzip -9 $D.tar
  exit
fi

if [ "$1" = "cleanup" ]; then
  cd ~/.konilo || exit
  echo "Removing old backups:"
  find ~/.konilo/*.gz -mtime +30 -type f
  find ~/.konilo/*.gz -mtime +30 -type f -delete
  exit
fi

if [ "$1" = "restore" ]; then
  cd ~/.konilo || exit
  D=$(stat -f "%m%t%N" *.gz | sort -rn | head -1 | cut -f2-)
  echo "Restoring from: $D"
  tar xzvf $D
  exit
fi

if [ "$1" = "restore-from" ]; then
  cd ~/.konilo || exit
  echo "Restoring from: $2"
  tar xzvf $2
  exit
fi

if [ "$1" = "list-backups" ]; then
  cd ~/.konilo || exit
  ls -l *.tar.gz
  exit
fi

# --------------------------------------------------------------
# Help
# --------------------------------------------------------------

if [ "$1" = "help" ]; then
  echo "$0 help"
  echo "   Display this help text"


@@ 268,6 313,21 @@ if [ "$1" = "help" ]; then
  echo "$0 update"
  echo "   Update the Konilo image & system blocks"
  echo
  echo "$0 backup"
  echo "   Make a backup of ilo.rom and ilo.blocks"
  echo
  echo "$0 restore"
  echo "   Restore from the the latest backup"
  echo
  echo "$0 restore-from filename"
  echo "   Restore from a specific backup"
  echo
  echo "$0 cleanup"
  echo "   Remove backups older than 30 days"
  echo
  echo "$0 list-backups"
  echo "   Display a list of backups"
  echo
  echo "$0"
  echo "   Start Konilo"
  echo