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.

327 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

  195. Pingback: Extreme incense

  196. Pingback: SEO Service

  197. Pingback: 5euros

  198. Pingback: consultant seo

  199. Pingback: Webinar

  200. Pingback: آنال سکس کثیف

  201. Pingback: pay n play casino bonus

  202. Pingback: سكس زنوج جماعي

  203. Pingback: Phone number location

  204. Pingback: big black cock enter's rajapandi's tender asshole

  205. Pingback: Handlateknik

  206. Pingback: ثقة

  207. Pingback: غرور كبرياء

  208. Pingback: الغدر والخيانة

  209. Pingback: حلوه خيال

  210. Pingback: الم

  211. Pingback: Amsterdam escorts

  212. Pingback: 5euros

  213. Pingback: Kratom near me

  214. Pingback: https://royalcbd.com/category/knowledge/

  215. Pingback: local guides

  216. Pingback: RoyalCBD.com

  217. Pingback: RoyalCBD

  218. Pingback: RoyalCBD.com

  219. Pingback: https://royalcbd.com/cbd-oil-cost/

  220. Pingback: https://royalcbd.com/best-time-of-day-to-take-cbd-oil/

  221. Pingback: RoyalCBD.com

  222. Pingback: cbd drug interactions

  223. Pingback: https://royalcbd.com/can-you-overdose-on-cbd/

  224. Pingback: Royal CBD

  225. Pingback: RoyalCBD

  226. Pingback: RoyalCBD.com

  227. Pingback: https://royalcbd.com/cbd-dosage-for-dogs

  228. Pingback: Royal CBD

  229. Pingback: Royal CBD

  230. Pingback: cbd washington dc

  231. Pingback: Royal CBD

  232. Pingback: RoyalCBD

  233. Pingback: cbd oil oklahoma

  234. Pingback: Royal CBD

  235. Pingback: cbd oil utah

  236. Pingback: cbd north dakota

  237. Pingback: Royal CBD

  238. Pingback: is cbd legal in tennessee

  239. Pingback: RoyalCBD.com

  240. Pingback: RoyalCBD

  241. Pingback: is cbd legal in rhode island

  242. Pingback: is cbd legal in pennsylvania

  243. Pingback: new york cbd

  244. Pingback: RoyalCBD.com

  245. Pingback: cbd new hampshire

  246. Pingback: https://royalcbd.com/montana/

  247. Pingback: Royal CBD

  248. Pingback: is cbd legal in missouri

  249. Pingback: RoyalCBD

  250. Pingback: cbd michigan

  251. Pingback: cbd maryland

  252. Pingback: cbd massachusetts

  253. Pingback: RoyalCBD.com

  254. Pingback: https://royalcbd.com/maine/

  255. Pingback: RoyalCBD.com

  256. Pingback: is cbd legal in florida

  257. Pingback: georgia cbd

  258. Pingback: cbd oil connecticut

  259. Pingback: cbd delaware

  260. Pingback: cbd oil arkansas

  261. Pingback: colorado

  262. Pingback: Royal CBD

  263. Pingback: california

  264. Pingback: RoyalCBD.com

  265. Pingback: RoyalCBD

  266. Pingback: RoyalCBD

  267. Pingback: how to make cbd gummies at home

  268. Pingback: beginner guide cbd oil

  269. Pingback: RoyalCBD

  270. Pingback: https://royalcbd.com/cbd-oil-timeline

  271. Pingback: RoyalCBD.com

  272. Pingback: https://royalcbd.com/cbd-oil-recipes/

  273. Pingback: RoyalCBD

  274. Pingback: RoyalCBD

  275. Pingback: cbd isolate vs full spectrum broad spectrum

  276. Pingback: why cannabis affects people differently

  277. Pingback: https://royalcbd.com/why-cbd-oil-not-certified-organic/

  278. Pingback: https://royalcbd.com/cbd-oil-hemp-vs-marijuana/

  279. Pingback: RoyalCBD.com

  280. Pingback: Royal CBD

  281. Pingback: Royal CBD

  282. Pingback: RoyalCBD

  283. Pingback: RoyalCBD

  284. Pingback: Dank Vapes Cartridge

  285. Pingback: اغاني

  286. Pingback: MILF

  287. Pingback: lesbian porn

  288. Pingback: freie presse partnersuche er sucht sie

  289. Pingback: map rust

  290. Pingback: MALWAREBYTES BROWSER GUARD

  291. Pingback: commercial real estate

  292. Pingback: Electrician SEO

  293. Pingback: free download for windows

  294. Pingback: free download for pc windows

  295. Pingback: free games download for pc

  296. Pingback: apps for pc download

  297. Pingback: pc games for windows 10

  298. Pingback: Kabza De Small

  299. Pingback: Escort amsterdam

  300. Pingback: Health Coaches

  301. Pingback: anvelope chisinau

  302. Pingback: options trading

  303. Pingback: Online Impacts

  304. Pingback: Apple reparatur

  305. Pingback: affiliate link

  306. Pingback: news websites like yahoo

  307. Pingback: Pomeranian Puppies

  308. Pingback: pricing semrush

  309. Pingback: Buy marijuana online

  310. Pingback: Brass knuckles Vape

  311. Pingback: Teacup Puppies for Adoption

  312. Pingback: Escorts amsterdam

  313. Pingback: Pc support meilen

  314. Pingback: Employee Benefits Chicago

  315. Pingback: gamer

  316. Pingback: Anthony Galie

  317. Pingback: tube top swimsuits

  318. Pingback: HOTELS

  319. Pingback: quality counterfeit money for sale

  320. Pingback: الکسیس تگزاس

  321. Pingback: https://sharadadvertising.com/

  322. Pingback: questions for couples

  323. Pingback: undetectable counterfeit money for sale

  324. Pingback: basset

  325. Pingback: fishscale cocaine

  326. Pingback: fake money online

  327. Pingback: اغاني

Leave a Reply