xartin

mkstage4.sh

Jul 13th, 2019 (edited)
815
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. #! /bin/bash
  2. ## Backup script for Gentoo Linux
  3. ## Author: BrianW
  4. ## Date: 2004.10.26.
  5. ## Adapted from backupHome.sh by fdavid
  6. ## Further adapted by nianderson
  7.  
  8. ## This is a script to create a custom stage 4 tarball (System and boot backup)
  9. ## I use this script to make a snapshot of my system. Meant to be done weekly in my case
  10.  
  11. ## Please check the options and adjust to your specifics.
  12.  
  13. echo -=- Starting the Backup Script...
  14. echo -=-
  15.  
  16. ## Mounting the boot partition
  17. echo -=- Mounting boot partition, then sleeping for 5 seconds...
  18. mount /boot
  19. sleep 5
  20. echo -=- Done!
  21. echo -=-
  22.  
  23. echo -=- Setting the variables...
  24.  
  25. ## The location of the stage 4 tarball.
  26. ## Be sure to include a trailing /
  27. stage4Location=/
  28.  
  29. ## The name of the stage 4 tarball.
  30. archive=$stage4Location$(hostname)-$(date +%F_%H-%M)-stage4.tar.xz
  31.  
  32. ## Directories/files that will be exluded from the stage 4 tarball.
  33. ##
  34. ## Add directories that will be recursively excluded, delimited by a space.
  35. ## Be sure to omit the trailing /
  36. dir_excludes="/proc /sys /run /cornhub"
  37. ##
  38. ## Add files that will be excluded, delimited by a space.
  39. ## You can use the * wildcard for multiple matches.
  40. ## There should always be $archive listed or bad things will happen.
  41. file_excludes="$archive"
  42. ##
  43. ## Combine the two *-excludes variables into the $excludes variable
  44. excludes="$(for i in $dir_excludes; do if [ -d $i ]; then echo -n " --exclude=$i/*"; fi; done) $(for i in $file_excludes; do echo -n " --exclude=$i"; done)"
  45.  
  46. ## The options for the stage 4 tarball.
  47. tarOptions="$excludes --create --xz --absolute-names --preserve-permissions --xattrs --acls --verbose --file"
  48.  
  49. echo -=- Done!
  50. echo -=-
  51.  
  52. ## Creating the stage 4 tarball.
  53. echo -=- Creating custom stage 4 tarball \=\=\> $archive
  54. echo -=-
  55. echo -=- Running the following command:
  56. echo -=- tar ${tarOptions} ${archive} /
  57. tar ${tarOptions} ${archive} /;
  58. echo -=- Done!
  59.  
  60. ## Unmounting /boot
  61. echo -=- Unmounting /boot then sleeping for 5 seconds...
  62. umount /boot/efi
  63. sleep 5
  64. echo -=- Done!
  65. echo -=-
  66.  
  67. ## Split the stage 4 tarball in cd size tar files.
  68. ## Use: "cat ${archive}.* >> ${archive}" to join the tar files into a stage 4 tarball.
  69. ## Uncomment the following lines to enable this feature.
  70. #echo -=- Splitting the stage 4 tarball into CD size tar files...
  71. #split --bytes=700000000 ${archive} ${archive}.
  72. #echo -=- Done!
  73.  
  74. ## This is the end of the line.
  75. echo -=- The Backup Script has completed!
Add Comment
Please, Sign In to add comment