backup-restore 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. ################################################################################
  3. # This file is part of OpenELEC - http://www.openelec.tv
  4. # Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv)
  5. #
  6. # OpenELEC is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # OpenELEC is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with OpenELEC. If not, see <http://www.gnu.org/licenses/>.
  18. ################################################################################
  19. BACKUP_FILE=`ls -1 /storage/.restore/??????????????.tar 2>/dev/null | tail -1`
  20. if [ -f "$BACKUP_FILE" ] ; then
  21. echo -en "please wait.. checking backup file: "
  22. tar tf $BACKUP_FILE &>/dev/null
  23. ret=$?
  24. if [ $ret -eq 0 ] ; then
  25. echo OK
  26. echo -en "restoring.. this may take long time to complete, please wait.. "
  27. rm -rf /storage/.kodi &>/dev/null
  28. rm -rf /storage/.cache &>/dev/null
  29. rm -rf /storage/.config &>/dev/null
  30. tar xf $BACKUP_FILE -C / &>/dev/null
  31. rm -f $BACKUP_FILE &>/dev/null
  32. echo done
  33. echo "rebooting in 5s..."
  34. sleep 5
  35. else
  36. echo FAILED
  37. rm -f $BACKUP_FILE &>/dev/null
  38. echo "rebooting in 30s..."
  39. sleep 30
  40. fi
  41. fi
  42. sync
  43. reboot -f