Gerrit Backup Script

Here’s a cool cron script I wrote to backup your Gerrit¬†instance to a shared folder:

Some requirements and assumptions:

  • You’ll need 7z available on the path.
  • Edit the share location and the username and password.
  • Keeps the past 30 days of all back-ups on the server.
  • Keeps the past 14 days of MySQL backups on the share. Edit the corresponding value in the script to change as you need it.
  • Keeps the past 7 days of Gerrit backups on the share. Edit the corresponding value in the script to change as you need it.
  • MySQL is used for Gerrit’s datastore You can remove those sections if you’re not using it. Just make sure you’re backing up the datastore!
#!/bin/bash

# Backup the mysql databases
mysqldump-secure --cron

# Remove old backups
find /var/backups/mysql/* -mtime +30 -exec rm {} \;

#Gerrit Home Directory Filename
filename="gerrit-home-$(date '+%F-%H%M').tar.7z"

echo "Starting backup of gerrit home directory..."
#Perform Backup of the gerrit home directory.
tar -cf - /home/gerrit | 7z a -si "/var/backups/gerrit/$filename"
echo "Backup of home directory completed!"

echo "Removing old backups..."
#Remove old backups
find /var/backups/gerrit/* -mtime +30 -exec rm {} \;
echo "Completed removing old backups."

#make the share folder incase it's gone.
if [ ! -d "/mnt/backup-share" ]; then
	mkdir /mnt/backup-share
fi

#mount the CIFS share for the backup location
mount -t cifs -o username=rodsqladmin,password=*r6fE?eW //GVLVIDFSCS02P/MGardner$ /mnt/backup-share/

#make the share folder incase it's gone.
if [ ! -d "/tmp/tobackup" ]; then
        mkdir /tmp/tobackup
fi
if [ ! -d "/tmp/tobackup/mysql" ]; then
        mkdir /tmp/tobackup/mysql/
fi
if [ ! -d "/tmp/tobackup/gerrit" ]; then
        mkdir /tmp/tobackup/gerrit/
fi

echo "Preparing backups for copying..."
find /var/backups/mysql -type f -mtime -14 > /tmp/tobackup/mysql
find /var/backups/gerrit -type f -mtime -7 > /tmp/tobackup/gerrit

echo "Copying backups..."
#Rsync the backups
rsync -a /tmp/tobackup/mysql/ /mnt/backup-share/mysql
rsync -a /tmp/tobackup/gerrit/ /mnt/backup-share/gerrit
echo "Copying complete!"

echo "Performing final cleanup..."

find /mnt/backup-share/mysql/* -mtime +14 -exec rm {} \;
find /mnt/backup-share/gerrit/* -mtime +7 -exec rm {} \;

rm -rf /tmp/tobackup

echo "Cleanup complete!"

echo "Unmounting share and wrapping up!"

#unmount the share
umount /mnt/backup-share

echo "Backup complete!"

I’ve placed this script in my /etc/cron.daily folder to have it run once a day.

Tagged , , . Bookmark the permalink.

About Mike

I'm a software engineer. Look into the about page for more information about me.

194 Responses to Gerrit Backup Script

  1. Pingback: Google

  2. Pingback: hairdressing scissors icandy

  3. Pingback: Email

  4. Pingback: hairdressing scissors

  5. Pingback: cbd oil Australia

  6. Pingback: dildo

  7. Pingback: side jobs near me

  8. Pingback: Pest control for ants

  9. Pingback: grid inverter

  10. Pingback: mens rings online

  11. Pingback: vibrator reviews

  12. Pingback: free laptop games download

  13. Pingback: app free download for windows 7

  14. Pingback: free app for pclaptop

  15. Pingback: free download for laptop pc

  16. Pingback: app for pc

  17. Pingback: app for pc

  18. Pingback: free download for windows 10

  19. Pingback: free download for windows 8

  20. Pingback: app free download for windows 8

  21. Pingback: app free download for windows 10

  22. Pingback: moon rocks

  23. Pingback: Rick simpson oil

  24. Pingback: hairdressing scissors matsui

  25. Pingback: best CBD oil

  26. Pingback: Calgary Scrap Car Removal and Auto Salvage

  27. Pingback: sex drug

  28. Pingback: elite chinese scissors

  29. Pingback: best CBD oil

  30. Pingback: education

  31. Pingback: Royal CBD

  32. Pingback: buy CBD oil

  33. Pingback: CBD gummies for anxiety

  34. Pingback: Royal CBD

  35. Pingback: best CBD

  36. Pingback: carte prepagate

  37. Pingback: Richard harmond net worth

  38. Pingback: app download for windows

  39. Pingback: prostate milking toys

  40. Pingback: g spot finger vibrator

  41. Pingback: pocket stroker

  42. Pingback: best CBD pills

  43. Pingback: Royal CBD

  44. Pingback: best CBD oil

  45. Pingback: CBD pills

  46. Pingback: CBD gummies

  47. Pingback: Buy Marijuana online

  48. Pingback: pegging panty

  49. Pingback: big white dildo

  50. Pingback: CBD products

  51. Pingback: Royal CBD

  52. Pingback: CBD cream

  53. Pingback: vibrating butt plug

  54. Pingback: flour mill

  55. Pingback: penis extender

  56. Pingback: dank vapes

  57. Pingback: CBD products

  58. Pingback: Royal CBD

  59. Pingback: best CBD oil

  60. Pingback: best cbd cream for pain

  61. Pingback: best cbd cream for pain

  62. Pingback: Macaw

  63. Pingback: LSD Blotters

  64. Pingback: Glockstore

  65. Pingback: THC Oil

  66. Pingback: DMT Powder

  67. Pingback: lesbian strapon

  68. Pingback: suction cup dong

  69. Pingback: flexible dildo

  70. Pingback: sex toy

  71. Pingback: Consultant SEO

  72. Pingback: buy crystal meth

  73. Pingback: xanax online

  74. Pingback: Buy exotic carts

  75. Pingback: buy ativanbuy lorazepam online

  76. Pingback: cialis buy generic

  77. Pingback: English bulldog puppies for sale

  78. Pingback: جزمة

  79. Pingback: buy CBD oil

  80. Pingback: MALWAREBYTES APP

  81. Pingback: best CBD oil for arthritis

  82. Pingback: best CBD oil for dogs

  83. Pingback: best CBD oil for sleep

  84. Pingback: best CBD oil for pain

  85. Pingback: best CBD capsules

  86. Pingback: best CBD oil for dogs

  87. Pingback: best CBD oil for sleep

  88. Pingback: best CBD cream for arthritis pain

  89. Pingback: best CBD gummies

  90. Pingback: buy CBD oil

  91. Pingback: best CBD gummies

  92. Pingback: CBD oil for anxiety

  93. Pingback: best CBD oil for anxiety

  94. Pingback: best CBD oil for pain

  95. Pingback: best CBD oil

  96. Pingback: best CBD oil

  97. Pingback: best CBD oil

  98. Pingback: best CBD oil

  99. Pingback: best CBD oil

  100. Pingback: best CBD oil

  101. Pingback: best CBD gummies

  102. Pingback: best CBD gummies

  103. Pingback: free games for pc download

  104. Pingback: free download for windows 10

  105. Pingback: app free download for windows 7

  106. Pingback: free download for pc windows

  107. Pingback: apps download for windows 7

  108. Pingback: apps download for pc

  109. Pingback: app for pc

  110. Pingback: app free download for windows 10

  111. Pingback: app free download for windows 8

  112. Pingback: free download for windows pc

  113. Pingback: app for laptop

  114. Pingback: free download for laptop

  115. Pingback: free app for pclaptop

  116. Pingback: free download for windows pc

  117. Pingback: roulette software

  118. Pingback: vape shop near me

  119. Pingback: how to win at roulette

  120. Pingback: knight rider kitt

  121. Pingback: pinoy tambayan

  122. Pingback: best roulette software

  123. Pingback: win at online casino

  124. Pingback: make money fast

  125. Pingback: Balance CBD - Scam CBD Oil

  126. Pingback: backlink

  127. Pingback: kratom near me

  128. Pingback: bàn học thông minh hà nội

  129. Pingback: buy CBD oil

  130. Pingback: best CBD oils UK

  131. Pingback: Blessed CBD

  132. Pingback: CBD products

  133. Pingback: best CBD oil

  134. Pingback: CBD oil UK

  135. Pingback: CBD oil for arthritis

  136. Pingback: CBD oil UK

  137. Pingback: CBD oils UK

  138. Pingback: CBD oil for depression

  139. Pingback: buy CBD oils

  140. Pingback: buy CBD oils

  141. Pingback: free instagram followers

  142. Pingback: Buy research chemicals online

  143. Pingback: OxyContin for sale

  144. Pingback: websites

  145. Pingback: White Shepherd puppies for sale

  146. Pingback: wartaekonomi

  147. Pingback: Online jobs

  148. Pingback: Earn Money Online

  149. Pingback: Earn Money Online

  150. Pingback: Online jobs

  151. Pingback: Online jobs

  152. Pingback: bitcoin slots

  153. Pingback: free app for pc download

  154. Pingback: app download for pc

  155. Pingback: free download for windows 8

  156. Pingback: apk for pc download

  157. Pingback: free apk app download

  158. Pingback: free apps for pc download

  159. Pingback: apps apk for windows pc download

  160. Pingback: apps download for windows 7

  161. Pingback: free apps download for windows 10

  162. Pingback: app download for windows 8

  163. Pingback: free download for windows pc

  164. Pingback: pc games for windows 10

  165. Pingback: kratom near me

  166. Pingback: flow bar nz

  167. Pingback: Umzugsfirma Wien

  168. Pingback: Забавы эроТВ молодой парочки по данному url

  169. Pingback: Jed Fernandez

  170. Pingback: AC maintenance in dubai

  171. Pingback: comprar likes

  172. Pingback: Sonia Randhawa

  173. Pingback: free download for pc

  174. Pingback: International Rajabhat Univerty

  175. Pingback: job search

  176. Pingback: fake money for sale

  177. Pingback: sphynx kittens for sale near me

  178. Pingback: counterfeit money for sale 

  179. Pingback: Ayurveda Online Shop

  180. Pingback: Sonia Randhawa

  181. Pingback: Sonia Randhawa

  182. Pingback: kratom near me

  183. Pingback: kratom near me

  184. Pingback: London escort

  185. Pingback: cbd cats

  186. Pingback: cbd for pain

  187. Pingback: maeng da kratom

  188. Pingback: Sonia Randhawa

  189. Pingback: Sonia Randhawa

  190. Pingback: Sonia Randhawa

  191. Pingback: 5euros

  192. Pingback: Sonia Randhawa

  193. Pingback: Sonia Randhawa

  194. Pingback: Sonia Randhawa

Leave a Reply