Advertisement
J2897

[Cygwin] Duplicity - Restore

Feb 15th, 2016
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.17 KB | None | 0 0
  1. #!/bin/bash
  2. clear
  3. ulimit -n 1024
  4.  
  5. # Restores Duplicity backups via Cygwin.
  6. #------------------------------------------------------------------------------
  7. # Set the source, destination, GPG key ID, the restore time and a temporary mount-point.
  8. BACKUP=file://$(cygpath "J:\dest")
  9. DUMP=$(cygpath "$SYSTEMDRIVE\dump")
  10. WIN_DUMP=$(cygpath -w "$DUMP")
  11. KEY=012EE35A
  12. RT=2016-02-18T20:33:53
  13. T_MP=/tmp/dump/
  14. #------------------------------------------------------------------------------
  15. # Is Duplicity installed?
  16. if !(cygcheck -cd duplicity | grep -q duplicity)
  17. then
  18.     echo "Please install the 'Duplicity' package for Cygwin."
  19.     exit 1
  20. fi
  21. #------------------------------------------------------------------------------
  22. # Does the destination exist?
  23. if [ -d "$DUMP" ]
  24. then
  25.     echo "Destination already exists. I refuse to destroy your pretty data flowers."
  26.     exit 1
  27. else
  28.     mkdir "$DUMP"
  29. fi
  30. #------------------------------------------------------------------------------
  31. # Prepare permissions.
  32. setfacl -b "$DUMP"
  33. #------------------------------------------------------------------------------
  34. # Create a temporary mount-point without POSIX permissions.
  35. if [ -d "$T_MP" ]
  36. then
  37.     rm -rf "$T_MP"
  38. fi
  39. mkdir $T_MP
  40. mount -o binary,posix=0,user,noacl $WIN_DUMP $T_MP
  41. #------------------------------------------------------------------------------
  42. # The passphrase you set during the GPG key creation.
  43. export PASSPHRASE=qZSt3rigV0wDW9t43BtpAQC066F
  44. export SIGN_PASSPHRASE=$PASSPHRASE
  45. #------------------------------------------------------------------------------
  46. # Restore.
  47. duplicity --encrypt-key=$KEY --sign-key=$KEY --restore-time "$RT" "$BACKUP" "$T_MP"
  48. #------------------------------------------------------------------------------
  49. # Clear the variables.
  50. unset SIGN_PASSPHRASE
  51. unset PASSPHRASE
  52. unset WIN_DUMP
  53. unset BACKUP
  54. unset DUMP
  55. unset KEY
  56. unset RT
  57. #------------------------------------------------------------------------------
  58. # End.
  59. echo "Finished!"
  60. umount $T_MP
  61. unset T_MP
  62. exit 0
  63. #------------------------------------------------------------------------------
  64. # Information.
  65. #duplicity collection-status "$BACKUP"
  66. #duplicity list-current-files "$BACKUP" | grep "test.txt"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement