freedombone-restore-local 36KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Restore from local storage - typically a USB drive
  12. # License
  13. # =======
  14. #
  15. # Copyright (C) 2015-2016 Bob Mottram <bob@robotics.uk.to>
  16. #
  17. # This program is free software: you can redistribute it and/or modify
  18. # it under the terms of the GNU General Public License as published by
  19. # the Free Software Foundation, either version 3 of the License, or
  20. # (at your option) any later version.
  21. #
  22. # This program is distributed in the hope that it will be useful,
  23. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. # GNU General Public License for more details.
  26. #
  27. # You should have received a copy of the GNU General Public License
  28. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  29. PROJECT_NAME='freedombone'
  30. COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt
  31. BACKUP_EXTRA_DIRECTORIES=/root/backup-extra-dirs.csv
  32. # whether to restore everything or just a specific application
  33. RESTORE_APP='all'
  34. export TEXTDOMAIN=${PROJECT_NAME}-restore-local
  35. export TEXTDOMAINDIR="/usr/share/locale"
  36. USB_DRIVE=/dev/sdb1
  37. USB_MOUNT=/mnt/usb
  38. # get default USB from config file
  39. CONFIG_FILE=$HOME/${PROJECT_NAME}.cfg
  40. if [ -f $CONFIG_FILE ]; then
  41. if grep -q "USB_DRIVE=" $CONFIG_FILE; then
  42. USB_DRIVE=$(cat $CONFIG_FILE | grep "USB_DRIVE=" | awk -F '=' '{print $2}')
  43. fi
  44. fi
  45. ADMIN_USERNAME=
  46. ADMIN_NAME=
  47. # MariaDB password
  48. DATABASE_PASSWORD=$(cat /root/dbpass)
  49. MICROBLOG_DOMAIN_NAME=
  50. HUBZILLA_DOMAIN_NAME=
  51. OWNCLOUD_DOMAIN_NAME=
  52. GIT_DOMAIN_NAME=
  53. WIKI_DOMAIN_NAME=
  54. FULLBLOG_DOMAIN_NAME=
  55. function mount_drive {
  56. if [ $1 ]; then
  57. USB_DRIVE=/dev/${1}1
  58. fi
  59. # get the admin user
  60. ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
  61. if [ $2 ]; then
  62. ADMIN_USERNAME=$2
  63. fi
  64. ADMIN_NAME=$(getent passwd $ADMIN_USERNAME | cut -d: -f5 | cut -d, -f1)
  65. # check that the backup destination is available
  66. if [ ! -b $USB_DRIVE ]; then
  67. echo $"Please attach a USB drive"
  68. exit 1
  69. fi
  70. # unmount if already mounted
  71. umount -f $USB_MOUNT
  72. if [ ! -d $USB_MOUNT ]; then
  73. mkdir $USB_MOUNT
  74. fi
  75. if [ -f /dev/mapper/encrypted_usb ]; then
  76. rm -rf /dev/mapper/encrypted_usb
  77. fi
  78. cryptsetup luksClose encrypted_usb
  79. # mount the encrypted backup drive
  80. cryptsetup luksOpen $USB_DRIVE encrypted_usb
  81. if [ "$?" = "0" ]; then
  82. USB_DRIVE=/dev/mapper/encrypted_usb
  83. fi
  84. mount $USB_DRIVE $USB_MOUNT
  85. if [ ! "$?" = "0" ]; then
  86. echo $"There was a problem mounting the USB drive to $USB_MOUNT"
  87. rm -rf $USB_MOUNT
  88. exit 2
  89. fi
  90. }
  91. function unmount_drive {
  92. sync
  93. umount $USB_MOUNT
  94. if [ ! "$?" = "0" ]; then
  95. echo $"Unable to unmount the drive. This means that the backup did not work"
  96. rm -rf $USB_MOUNT
  97. exit 9
  98. fi
  99. rm -rf $USB_MOUNT
  100. echo $"Setting permissions"
  101. for d in /home/*/ ; do
  102. USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
  103. if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
  104. chown -R $USERNAME:$USERNAME /home/$USERNAME
  105. fi
  106. done
  107. if [[ $USB_DRIVE == /dev/mapper/encrypted_usb ]]; then
  108. echo $"Unmount encrypted USB"
  109. cryptsetup luksClose encrypted_usb
  110. fi
  111. if [ -f /dev/mapper/encrypted_usb ]; then
  112. rm -rf /dev/mapper/encrypted_usb
  113. fi
  114. }
  115. function check_backup_exists {
  116. if [ ! -d $USB_MOUNT/backup ]; then
  117. echo $"No backup directory found on the USB drive."
  118. unmount_drive
  119. exit 2
  120. fi
  121. }
  122. function check_admin_user {
  123. echo $"Checking that admin user exists"
  124. if [ ! -d /home/$ADMIN_USERNAME ]; then
  125. echo $"Username $ADMIN_USERNAME not found. Reinstall ${PROJECT_NAME} with this username."
  126. unmount_drive
  127. exit 295
  128. fi
  129. }
  130. function copy_gpg_keys {
  131. echo $"Copying GPG keys from admin user to root"
  132. cp -r /home/$ADMIN_USERNAME/.gnupg /root
  133. }
  134. function restore_directory_from_usb {
  135. if [ ! -d ${1} ]; then
  136. mkdir ${1}
  137. fi
  138. obnam restore -r $USB_MOUNT/backup/${2} --to ${1}
  139. }
  140. function restore_database {
  141. RESTORE_SUBDIR="root"
  142. if [ -d $USB_MOUNT/backup/${1} ]; then
  143. echo $"Restoring ${1} database"
  144. restore_directory_from_usb "/root/temp${1}data" "${1}data"
  145. if [ ! -f /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql ]; then
  146. echo $"Unable to restore ${1} database"
  147. rm -rf /root/temp${1}data
  148. unmount_drive
  149. exit 503
  150. fi
  151. mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD ${1} -o < /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/${1}.sql)
  152. if [ ! "$?" = "0" ]; then
  153. echo "$mysqlsuccess"
  154. unmount_drive
  155. exit 964
  156. fi
  157. shred -zu /root/temp${1}data/${RESTORE_SUBDIR}/temp${1}data/*
  158. rm -rf /root/temp${1}data
  159. echo $"Restoring ${1} installation"
  160. if [ ! -d /root/temp${1} ]; then
  161. mkdir /root/temp${1}
  162. fi
  163. restore_directory_from_usb "/root/temp${1}" "${1}"
  164. RESTORE_SUBDIR="var"
  165. if [ ${2} ]; then
  166. # special handline of ttrss
  167. if [[ ${2} == "ttrss" ]]; then
  168. if [ -d /etc/share/tt-rss ]; then
  169. if [ -d /root/temp${1}/etc/share/tt-rss ]; then
  170. rm -rf /etc/share/tt-rss
  171. mv /root/temp${1}/etc/share/tt-rss /etc/share/
  172. if [ ! "$?" = "0" ]; then
  173. unmount_drive
  174. exit 528
  175. fi
  176. if [ -d /etc/letsencrypt/live/${2} ]; then
  177. ln -s /etc/letsencrypt/live/${2}/privkey.pem /etc/ssl/private/${2}.key
  178. ln -s /etc/letsencrypt/live/${2}/fullchain.pem /etc/ssl/certs/${2}.pem
  179. else
  180. # Ensure that the bundled SSL cert is being used
  181. if [ -f /etc/ssl/certs/${2}.bundle.crt ]; then
  182. sed -i "s|${2}.crt|${2}.bundle.crt|g" /etc/nginx/sites-available/${2}
  183. fi
  184. fi
  185. fi
  186. fi
  187. fi
  188. if [ -d /var/www/${2}/htdocs ]; then
  189. if [ -d /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs ]; then
  190. rm -rf /var/www/${2}/htdocs
  191. mv /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs /var/www/${2}/
  192. if [ ! "$?" = "0" ]; then
  193. unmount_drive
  194. exit 683
  195. fi
  196. if [ -d /etc/letsencrypt/live/${2} ]; then
  197. ln -s /etc/letsencrypt/live/${2}/privkey.pem /etc/ssl/private/${2}.key
  198. ln -s /etc/letsencrypt/live/${2}/fullchain.pem /etc/ssl/certs/${2}.pem
  199. else
  200. # Ensure that the bundled SSL cert is being used
  201. if [ -f /etc/ssl/certs/${2}.bundle.crt ]; then
  202. sed -i "s|${2}.crt|${2}.bundle.crt|g" /etc/nginx/sites-available/${2}
  203. fi
  204. fi
  205. fi
  206. fi
  207. fi
  208. fi
  209. }
  210. function update_domains {
  211. if grep -q "RSS reader domain" $COMPLETION_FILE; then
  212. RSS_READER_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "RSS reader domain" | awk -F ':' '{print $2}')
  213. fi
  214. if grep -q "GNU Social domain" $COMPLETION_FILE; then
  215. MICROBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "GNU Social domain" | awk -F ':' '{print $2}')
  216. fi
  217. if grep -q "Hubzilla domain" $COMPLETION_FILE; then
  218. HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
  219. fi
  220. if grep -q "Owncloud domain" $COMPLETION_FILE; then
  221. OWNCLOUD_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Owncloud domain" | awk -F ':' '{print $2}')
  222. fi
  223. if grep -q "Gogs domain" $COMPLETION_FILE; then
  224. GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
  225. fi
  226. if [ -d $USB_MOUNT/backup/wiki ]; then
  227. WIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Wiki domain" | awk -F ':' '{print $2}')
  228. fi
  229. if [ -d $USB_MOUNT/backup/blog ]; then
  230. FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
  231. fi
  232. }
  233. function restore_configuration {
  234. if [[ $RESTORE_APP != 'all' ]]; then
  235. if [[ $RESTORE_APP != 'configuration' ]]; then
  236. return
  237. fi
  238. fi
  239. # this restores *.cfg and COMPLETION_FILE
  240. if [ -d $USB_MOUNT/backup/config ]; then
  241. echo $"Restoring configuration files"
  242. restore_directory_from_usb /root/tempconfig config
  243. cp -f /root/tempconfig/root/${PROJECT_NAME}.cfg $CONFIG_FILE
  244. if [ ! "$?" = "0" ]; then
  245. unmount_drive
  246. rm -rf /root/tempconfig
  247. exit 5294
  248. fi
  249. if [ -f $CONFIG_FILE ]; then
  250. # install according to the config file
  251. freedombone -c $CONFIG_FILE
  252. fi
  253. cp -f /root/tempconfig/root/${PROJECT_NAME}-completed.txt $COMPLETION_FILE
  254. if [ ! "$?" = "0" ]; then
  255. unmount_drive
  256. rm -rf /root/tempconfig
  257. exit 6382
  258. fi
  259. if [ -f /root/tempconfig${BACKUP_EXTRA_DIRECTORIES} ]; then
  260. cp -f /root/tempconfig${BACKUP_EXTRA_DIRECTORIES} ${BACKUP_EXTRA_DIRECTORIES}
  261. if [ ! "$?" = "0" ]; then
  262. unmount_drive
  263. rm -rf /root/tempconfig
  264. exit 62121
  265. fi
  266. fi
  267. rm -rf /root/tempconfig
  268. fi
  269. }
  270. function same_admin_user {
  271. PREV_ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
  272. if [[ "$PREV_ADMIN_USERNAME" != "$ADMIN_USERNAME" ]]; then
  273. echo $"The admin username has changed from $PREV_ADMIN_USERNAME to $ADMIN_USERNAME. To restore you will first need to install a new ${PROJECT_NAME} system with an initial admin user named $PREV_ADMIN_USERNAME"
  274. unmount_drive
  275. exit 73265
  276. fi
  277. }
  278. function restore_mariadb {
  279. if [[ $RESTORE_APP != 'all' ]]; then
  280. if [[ $RESTORE_APP != 'mariadb' ]]; then
  281. return
  282. fi
  283. fi
  284. if [ -d $USB_MOUNT/backup/mariadb ]; then
  285. echo $"Restoring mysql settings"
  286. restore_directory_from_usb /root/tempmariadb mariadb
  287. echo $"Get the MariaDB password from the backup"
  288. if [ ! -f /root/tempmariadb/root/tempmariadb/db ]; then
  289. echo $"MariaDB password file not found"
  290. exit 495
  291. fi
  292. BACKUP_MARIADB_PASSWORD=$(cat /root/tempmariadb/root/tempmariadb/db)
  293. if [[ $BACKUP_MARIADB_PASSWORD != $DATABASE_PASSWORD ]]; then
  294. echo $"Restore the MariaDB user table"
  295. mysqlsuccess=$(mysql -u root --password=$DATABASE_PASSWORD mysql -o < /root/tempmariadb/root/tempmariadb/mysql.sql)
  296. if [ ! "$?" = "0" ]; then
  297. echo $"Try again using the password obtained from backup"
  298. mysqlsuccess=$(mysql -u root --password=$BACKUP_MARIADB_PASSWORD mysql -o < /root/tempmariadb/root/tempmariadb/mysql.sql)
  299. fi
  300. if [ ! "$?" = "0" ]; then
  301. echo "$mysqlsuccess"
  302. unmount_drive
  303. exit 962
  304. fi
  305. echo $"Restarting database"
  306. service mysql restart
  307. echo $"Change the MariaDB password to the backup version"
  308. DATABASE_PASSWORD=$BACKUP_MARIADB_PASSWORD
  309. fi
  310. shred -zu /root/tempmariadb/root/tempmariadb/db
  311. rm -rf /root/tempmariadb
  312. # Change database password file
  313. echo "$DATABASE_PASSWORD" > /root/dbpass
  314. chmod 600 /root/dbpass
  315. fi
  316. }
  317. function restore_letsencrypt {
  318. if [[ $RESTORE_APP != 'all' ]]; then
  319. if [[ $RESTORE_APP != 'letsencrypt' ]]; then
  320. return
  321. fi
  322. fi
  323. if [ -d $USB_MOUNT/backup/letsencrypt ]; then
  324. echo $"Restoring Lets Encrypt settings"
  325. restore_directory_from_usb / letsencrypt
  326. fi
  327. }
  328. function restore_tor {
  329. if [[ $RESTORE_APP != 'all' ]]; then
  330. if [[ $RESTORE_APP != 'tor' ]]; then
  331. return
  332. fi
  333. fi
  334. if [ -d $USB_MOUNT/backup/tor ]; then
  335. echo $"Restoring Tor settings"
  336. restore_directory_from_usb / tor
  337. fi
  338. }
  339. function restore_mutt_settings {
  340. if [[ $RESTORE_APP != 'all' ]]; then
  341. if [[ $RESTORE_APP != 'mutt' ]]; then
  342. return
  343. fi
  344. fi
  345. if [ -d $USB_MOUNT/backup/mutt ]; then
  346. for d in $USB_MOUNT/backup/mutt/*/ ; do
  347. USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
  348. if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
  349. if [ ! -d /home/$USERNAME ]; then
  350. ${PROJECT_NAME}-adduser $USERNAME
  351. fi
  352. echo $"Restoring Mutt settings for $USERNAME"
  353. restore_directory_from_usb /root/tempmutt mutt/$USERNAME
  354. if [ -f /root/tempmutt/home/$USERNAME/tempbackup/.muttrc ]; then
  355. cp -f /root/tempmutt/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc
  356. fi
  357. if [ -f /root/tempmutt/home/$USERNAME/tempbackup/Muttrc ]; then
  358. cp -f /root/tempmutt/home/$USERNAME/tempbackup/Muttrc /etc/Muttrc
  359. fi
  360. if [ ! "$?" = "0" ]; then
  361. rm -rf /root/tempmutt
  362. unmount_drive
  363. exit 276
  364. fi
  365. rm -rf /root/tempmutt
  366. fi
  367. done
  368. fi
  369. }
  370. function restore_gpg {
  371. if [[ $RESTORE_APP != 'all' ]]; then
  372. if [[ $RESTORE_APP != 'gpg' ]]; then
  373. return
  374. fi
  375. fi
  376. if [ -d $USB_MOUNT/backup/gnupg ]; then
  377. for d in $USB_MOUNT/backup/gnupg/*/ ; do
  378. USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
  379. if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
  380. if [ ! -d /home/$USERNAME ]; then
  381. ${PROJECT_NAME}-adduser $USERNAME
  382. fi
  383. echo $"Restoring gnupg settings for $USERNAME"
  384. restore_directory_from_usb /root/tempgnupg gnupg/$USERNAME
  385. cp -r /root/tempgnupg/home/$USERNAME/.gnupg /home/$USERNAME/
  386. if [ ! "$?" = "0" ]; then
  387. rm -rf /root/tempgnupg
  388. unmount_drive
  389. exit 276
  390. fi
  391. rm -rf /root/tempgnupg
  392. if [[ "$USERNAME" == "$ADMIN_USERNAME" ]]; then
  393. cp -r /home/$USERNAME/.gnupg /root
  394. if [ ! "$?" = "0" ]; then
  395. unmount_drive
  396. exit 283
  397. fi
  398. fi
  399. fi
  400. done
  401. fi
  402. }
  403. function restore_procmail {
  404. if [[ $RESTORE_APP != 'all' ]]; then
  405. if [[ $RESTORE_APP != 'procmail' ]]; then
  406. return
  407. fi
  408. fi
  409. if [ -d $USB_MOUNT/backup/procmail ]; then
  410. for d in $USB_MOUNT/backup/procmail/*/ ; do
  411. USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
  412. if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
  413. if [ ! -d /home/$USERNAME ]; then
  414. ${PROJECT_NAME}-adduser $USERNAME
  415. fi
  416. echo $"Restoring procmail settings for $USERNAME"
  417. restore_directory_from_usb /root/tempprocmail procmail/$USERNAME
  418. cp -f /root/tempprocmail/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
  419. if [ ! "$?" = "0" ]; then
  420. rm -rf /root/tempprocmail
  421. unmount_drive
  422. exit 276
  423. fi
  424. rm -rf /root/tempprocmail
  425. fi
  426. done
  427. fi
  428. }
  429. function restore_spamassassin {
  430. if [[ $RESTORE_APP != 'all' ]]; then
  431. if [[ $RESTORE_APP != 'spamassassin' ]]; then
  432. return
  433. fi
  434. fi
  435. if [ -d $USB_MOUNT/backup/spamassassin ]; then
  436. for d in $USB_MOUNT/backup/spamassassin/*/ ; do
  437. USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
  438. if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
  439. if [ -d $USB_MOUNT/backup/spamassassin/$USERNAME ]; then
  440. if [ ! -d /home/$USERNAME ]; then
  441. ${PROJECT_NAME}-adduser $USERNAME
  442. fi
  443. echo $"Restoring spamassassin settings for $USERNAME"
  444. restore_directory_from_usb /root/tempspamassassin spamassassin/$USERNAME
  445. cp -rf /root/tempspamassassin/home/$USERNAME/.spamassassin /home/$USERNAME/
  446. if [ ! "$?" = "0" ]; then
  447. rm -rf /root/tempspamassassin
  448. unmount_drive
  449. exit 276
  450. fi
  451. rm -rf /root/tempspamassassin
  452. fi
  453. fi
  454. done
  455. fi
  456. }
  457. function restore_admin_readme {
  458. if [[ $RESTORE_APP != 'all' ]]; then
  459. if [[ $RESTORE_APP != 'readme' ]]; then
  460. return
  461. fi
  462. fi
  463. if [ -d $USB_MOUNT/backup/readme ]; then
  464. echo $"Restoring admin user README"
  465. # Make a backup of the original README file
  466. # incase old passwords need to be used
  467. if [ -f /home/$ADMIN_USERNAME/README ]; then
  468. if [ ! -f /home/$ADMIN_USERNAME/README_original ]; then
  469. cp /home/$ADMIN_USERNAME/README /home/$ADMIN_USERNAME/README_original
  470. fi
  471. fi
  472. restore_directory_from_usb /root/tempreadme readme
  473. cp -f /root/tempreadme/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
  474. if [ ! "$?" = "0" ]; then
  475. rm -rf /root/tempreadme
  476. unmount_drive
  477. exit 276
  478. fi
  479. rm -rf /root/tempreadme
  480. fi
  481. }
  482. function restore_ipfs {
  483. if [[ $RESTORE_APP != 'all' ]]; then
  484. if [[ $RESTORE_APP != 'ipfs' ]]; then
  485. return
  486. fi
  487. fi
  488. if [ -d $USB_MOUNT/backup/ipfs ]; then
  489. echo $"Restoring IPFS"
  490. restore_directory_from_usb /root/tempipfs ipfs
  491. cp -rf /root/tempipfs/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
  492. if [ ! "$?" = "0" ]; then
  493. rm -rf /root/tempipfs
  494. unmount_drive
  495. exit 276
  496. fi
  497. rm -rf /root/tempipfs
  498. fi
  499. }
  500. function restore_user_ssh_keys {
  501. if [[ $RESTORE_APP != 'all' ]]; then
  502. if [[ $RESTORE_APP != 'ssh' ]]; then
  503. return
  504. fi
  505. fi
  506. if [ -d $USB_MOUNT/backup/ssh ]; then
  507. for d in $USB_MOUNT/backup/ssh/*/ ; do
  508. USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
  509. if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
  510. if [ ! -d /home/$USERNAME ]; then
  511. ${PROJECT_NAME}-adduser $USERNAME
  512. fi
  513. echo $"Restoring ssh keys for $USERNAME"
  514. restore_directory_from_usb /root/tempssh ssh/$USERNAME
  515. cp -r /root/tempssh/home/$USERNAME/.ssh /home/$USERNAME/
  516. if [ ! "$?" = "0" ]; then
  517. rm -rf /root/tempssh
  518. unmount_drive
  519. exit 664
  520. fi
  521. rm -rf /root/tempssh
  522. fi
  523. done
  524. fi
  525. }
  526. function restore_user_config {
  527. if [[ $RESTORE_APP != 'all' ]]; then
  528. if [[ $RESTORE_APP != 'userconfig' ]]; then
  529. return
  530. fi
  531. fi
  532. if [ -d $USB_MOUNT/backup/config ]; then
  533. for d in $USB_MOUNT/backup/config/*/ ; do
  534. USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
  535. if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
  536. if [ ! -d /home/$USERNAME ]; then
  537. ${PROJECT_NAME}-adduser $USERNAME
  538. fi
  539. echo $"Restoring config files for $USERNAME"
  540. restore_directory_from_usb /root/tempconfig config/$USERNAME
  541. cp -r /root/tempconfig/home/$USERNAME/.config /home/$USERNAME/
  542. if [ ! "$?" = "0" ]; then
  543. rm -rf /root/tempconfig
  544. unmount_drive
  545. exit 664
  546. fi
  547. rm -rf /root/tempconfig
  548. fi
  549. done
  550. fi
  551. }
  552. function restore_certs {
  553. if [[ $RESTORE_APP != 'all' ]]; then
  554. if [[ $RESTORE_APP != 'certs' ]]; then
  555. return
  556. fi
  557. fi
  558. if [ -d $USB_MOUNT/backup/ssl ]; then
  559. echo $"Restoring certificates"
  560. mkdir /root/tempssl
  561. restore_directory_from_usb /root/tempssl ssl
  562. cp -r /root/tempssl/etc/ssl/* /etc/ssl
  563. if [ ! "$?" = "0" ]; then
  564. unmount_drive
  565. exit 276
  566. fi
  567. rm -rf /root/tempssl
  568. # restore ownership
  569. if [ -f /etc/ssl/private/xmpp.key ]; then
  570. chown prosody:prosody /etc/ssl/private/xmpp.key
  571. chown prosody:prosody /etc/ssl/certs/xmpp.*
  572. fi
  573. if [ -d /etc/dovecot ]; then
  574. chown root:dovecot /etc/ssl/private/dovecot.*
  575. chown root:dovecot /etc/ssl/certs/dovecot.*
  576. fi
  577. if [ -f /etc/ssl/private/exim.key ]; then
  578. cp /etc/ssl/private/exim.key /etc/exim4
  579. cp /etc/ssl/certs/exim.crt /etc/exim4
  580. cp /etc/ssl/certs/exim.dhparam /etc/exim4
  581. chown root:Debian-exim /etc/exim4/exim.key /etc/exim4/exim.crt /etc/exim4/exim.dhparam
  582. chmod 640 /etc/exim4/exim.key /etc/exim4/exim.crt /etc/exim4/exim.dhparam
  583. fi
  584. if [ -f /etc/ssl/private/mumble.key ]; then
  585. if [ -d /var/lib/mumble-server ]; then
  586. cp /etc/ssl/certs/mumble.* /var/lib/mumble-server
  587. cp /etc/ssl/private/mumble.key /var/lib/mumble-server
  588. chown -R mumble-server:mumble-server /var/lib/mumble-server
  589. fi
  590. fi
  591. fi
  592. }
  593. function restore_personal_settings {
  594. if [[ $RESTORE_APP != 'all' ]]; then
  595. if [[ $RESTORE_APP != 'personal' ]]; then
  596. return
  597. fi
  598. fi
  599. if [ -d $USB_MOUNT/backup/personal ]; then
  600. for d in $USB_MOUNT/backup/personal/*/ ; do
  601. USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
  602. if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
  603. if [ -d $USB_MOUNT/backup/personal/$USERNAME ]; then
  604. if [ ! -d /home/$USERNAME ]; then
  605. ${PROJECT_NAME}-adduser $USERNAME
  606. fi
  607. echo $"Restoring personal settings for $USERNAME"
  608. restore_directory_from_usb /root/temppersonal personal/$USERNAME
  609. if [ -d /home/$USERNAME/personal ]; then
  610. rm -rf /home/$USERNAME/personal
  611. fi
  612. mv /root/temppersonal/home/$USERNAME/personal /home/$USERNAME
  613. if [ ! "$?" = "0" ]; then
  614. unmount_drive
  615. exit 184
  616. fi
  617. rm -rf /root/temppersonal
  618. fi
  619. fi
  620. done
  621. fi
  622. }
  623. function restore_mailing_list {
  624. if [[ $RESTORE_APP != 'all' ]]; then
  625. if [[ $RESTORE_APP != 'mailinglist' ]]; then
  626. return
  627. fi
  628. fi
  629. if [ -d /var/spool/mlmmj ]; then
  630. echo $"Restoring public mailing list"
  631. restore_directory_from_usb /root/tempmailinglist mailinglist
  632. cp -r /root/tempmailinglist/root/spool/mlmmj/* /var/spool/mlmmj
  633. if [ ! "$?" = "0" ]; then
  634. unmount_drive
  635. exit 526
  636. fi
  637. rm -rf /root/tempmailinglist
  638. fi
  639. }
  640. function restore_xmpp {
  641. if [[ $RESTORE_APP != 'all' ]]; then
  642. if [[ $RESTORE_APP != 'xmpp' ]]; then
  643. return
  644. fi
  645. fi
  646. if [ -d /var/lib/prosody ]; then
  647. echo $"Restoring XMPP settings"
  648. restore_directory_from_usb /root/tempxmpp xmpp
  649. cp -r /root/tempxmpp/var/lib/prosody/* /var/lib/prosody
  650. if [ ! "$?" = "0" ]; then
  651. unmount_drive
  652. exit 725
  653. fi
  654. rm -rf /root/tempxmpp
  655. service prosody restart
  656. chown -R prosody:prosody /var/lib/prosody/*
  657. fi
  658. }
  659. function restore_gnu_social {
  660. if [[ $RESTORE_APP != 'all' ]]; then
  661. if [[ $RESTORE_APP != 'gnusocial' ]]; then
  662. return
  663. fi
  664. fi
  665. if [ $MICROBLOG_DOMAIN_NAME ]; then
  666. restore_database gnusocial ${MICROBLOG_DOMAIN_NAME}
  667. if [ -d /root/tempgnusocial ]; then
  668. rm -rf /root/tempgnusocial
  669. fi
  670. fi
  671. }
  672. function restore_rss_reader {
  673. if [[ $RESTORE_APP != 'all' ]]; then
  674. if [[ $RESTORE_APP != 'ttrss' ]]; then
  675. return
  676. fi
  677. fi
  678. if [ $RSS_READER_DOMAIN_NAME ]; then
  679. restore_database ttrss ${RSS_READER_DOMAIN_NAME}
  680. if [ -d $USB_MOUNT/backup/ttrss ]; then
  681. chown -R www-data:www-data /etc/share/tt-rss
  682. if [ -d /root/tempttrss ]; then
  683. rm -rf /root/tempttrss
  684. fi
  685. fi
  686. fi
  687. }
  688. function restore_hubzilla {
  689. if [[ $RESTORE_APP != 'all' ]]; then
  690. if [[ $RESTORE_APP != 'hubzilla' ]]; then
  691. return
  692. fi
  693. fi
  694. if [ $HUBZILLA_DOMAIN_NAME ]; then
  695. restore_database hubzilla ${HUBZILLA_DOMAIN_NAME}
  696. if [ -d $USB_MOUNT/backup/hubzilla ]; then
  697. if [ ! -d /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3 ]; then
  698. mkdir -p /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3
  699. fi
  700. chmod 777 /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3
  701. chown -R www-data:www-data /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/*
  702. if [ -d /root/temphubzilla ]; then
  703. rm -rf /root/temphubzilla
  704. fi
  705. fi
  706. fi
  707. }
  708. function restore_owncloud {
  709. if [[ $RESTORE_APP != 'all' ]]; then
  710. if [[ $RESTORE_APP != 'owncloud' ]]; then
  711. return
  712. fi
  713. fi
  714. if [ $OWNCLOUD_DOMAIN_NAME ]; then
  715. restore_database owncloud $OWNCLOUD_DOMAIN_NAME
  716. if [ -d $USB_MOUNT/backup/owncloud2 ]; then
  717. restore_directory_from_usb /root/tempowncloud2 owncloud2
  718. cp -r /root/tempowncloud2/etc/owncloud/* /etc/owncloud/
  719. if [ ! "$?" = "0" ]; then
  720. unmount_drive
  721. exit 982
  722. fi
  723. rm -rf /root/tempowncloud
  724. rm -rf /root/tempowncloud2
  725. chown -R www-data:www-data /var/lib/owncloud/data
  726. chown -R www-data:www-data /var/lib/owncloud/backup
  727. chown -R www-data:www-data /var/lib/owncloud/assets
  728. for d in /home/*/ ; do
  729. USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
  730. if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
  731. occ files:scan $USERNAME
  732. fi
  733. done
  734. ln -s /usr/share/owncloud /var/www/${OWNCLOUD_DOMAIN_NAME}/htdocs
  735. fi
  736. fi
  737. }
  738. function restore_gogs {
  739. if [[ $RESTORE_APP != 'all' ]]; then
  740. if [[ $RESTORE_APP != 'gogs' ]]; then
  741. return
  742. fi
  743. fi
  744. if [ $GIT_DOMAIN_NAME ]; then
  745. restore_database gogs ${GIT_DOMAIN_NAME}
  746. if [ -d $USB_MOUNT/backup/gogs ]; then
  747. echo $"Restoring Gogs settings"
  748. if [ ! -d /home/git/go/src/github.com/gogits/gogs/custom ]; then
  749. mkdir -p /home/git/go/src/github.com/gogits/gogs/custom
  750. fi
  751. cp -r /root/tempgogs/home/git/go/src/github.com/gogits/gogs/custom/* /home/git/go/src/github.com/gogits/gogs/custom
  752. if [ ! "$?" = "0" ]; then
  753. unmount_drive
  754. exit 981
  755. fi
  756. echo $"Restoring Gogs repos"
  757. restore_directory_from_usb /root/tempgogsrepos gogsrepos
  758. cp -r /root/tempgogsrepos/home/git/gogs-repositories/* /home/git/gogs-repositories/
  759. if [ ! "$?" = "0" ]; then
  760. unmount_drive
  761. exit 67574
  762. fi
  763. echo $"Restoring Gogs authorized_keys"
  764. restore_directory_from_usb /root/tempgogsssh gogsssh
  765. if [ ! -d /home/git/.ssh ]; then
  766. mkdir /home/git/.ssh
  767. fi
  768. cp -r /root/tempgogsssh/home/git/.ssh/* /home/git/.ssh/
  769. if [ ! "$?" = "0" ]; then
  770. unmount_drive
  771. exit 8463
  772. fi
  773. rm -rf /root/tempgogs
  774. rm -rf /root/tempgogsrepos
  775. rm -rf /root/tempgogsssh
  776. chown -R git:git /home/git
  777. fi
  778. fi
  779. }
  780. function restore_wiki {
  781. if [[ $RESTORE_APP != 'all' ]]; then
  782. if [[ $RESTORE_APP != 'wiki' ]]; then
  783. return
  784. fi
  785. fi
  786. if [ $WIKI_DOMAIN_NAME ]; then
  787. echo $"Restoring Wiki installation ${WIKI_DOMAIN_NAME}"
  788. restore_directory_from_usb /root/tempwiki wiki
  789. cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/
  790. if [ ! "$?" = "0" ]; then
  791. unmount_drive
  792. exit 868
  793. fi
  794. restore_directory_from_usb /root/tempwiki2 wiki2
  795. cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/
  796. if [ ! "$?" = "0" ]; then
  797. unmount_drive
  798. exit 869
  799. fi
  800. rm -rf /root/tempwiki
  801. rm -rf /root/tempwiki2
  802. chown -R www-data:www-data /var/lib/dokuwiki/*
  803. # Ensure that the bundled SSL cert is being used
  804. if [ -f /etc/ssl/certs/${WIKI_DOMAIN_NAME}.bundle.crt ]; then
  805. sed -i "s|${WIKI_DOMAIN_NAME}.crt|${WIKI_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${WIKI_DOMAIN_NAME}
  806. fi
  807. if [ -d /etc/letsencrypt/live/${WIKI_DOMAIN_NAME} ]; then
  808. ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${WIKI_DOMAIN_NAME}.key
  809. ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem
  810. fi
  811. fi
  812. }
  813. function restore_blog {
  814. if [[ $RESTORE_APP != 'all' ]]; then
  815. if [[ $RESTORE_APP != 'blog' ]]; then
  816. return
  817. fi
  818. fi
  819. if [ $FULLBLOG_DOMAIN_NAME ]; then
  820. echo $"Restoring blog installation"
  821. restore_directory_from_usb /root/tempblog blog
  822. rm -rf /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
  823. cp -r /root/tempblog/var/www/${FULLBLOG_DOMAIN_NAME}/htdocs /var/www/${FULLBLOG_DOMAIN_NAME}/
  824. if [ ! "$?" = "0" ]; then
  825. unmount_drive
  826. exit 593
  827. fi
  828. rm -rf /root/tempblog
  829. if [ ! -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content ]; then
  830. echo $"No content directory found after restoring blog"
  831. unmount_drive
  832. exit 287
  833. fi
  834. chown -R www-data:www-data /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs
  835. # Ensure that the bundled SSL cert is being used
  836. if [ -f /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.bundle.crt ]; then
  837. sed -i "s|${FULLBLOG_DOMAIN_NAME}.crt|${FULLBLOG_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${FULLBLOG_DOMAIN_NAME}
  838. fi
  839. for d in /home/*/ ; do
  840. USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
  841. if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
  842. if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; then
  843. mv /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/*.md /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post
  844. fi
  845. fi
  846. done
  847. if [ -d /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME} ]; then
  848. ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${FULLBLOG_DOMAIN_NAME}.key
  849. ln -s /etc/letsencrypt/live/${FULLBLOG_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${FULLBLOG_DOMAIN_NAME}.pem
  850. fi
  851. fi
  852. }
  853. function restore_cjdns {
  854. if [[ $RESTORE_APP != 'all' ]]; then
  855. if [[ $RESTORE_APP != 'cjdns' ]]; then
  856. return
  857. fi
  858. fi
  859. if [ -d $USB_MOUNT/backup/cjdns ]; then
  860. echo $"Restoring cjdns installation"
  861. restore_directory_from_usb /root/tempcjdns cjdns
  862. rm -rf /etc/cjdns
  863. cp -r /root/tempcjdns/etc/cjdns /etc/
  864. if [ ! "$?" = "0" ]; then
  865. unmount_drive
  866. exit 8472
  867. fi
  868. rm -rf /root/tempcjdns
  869. fi
  870. }
  871. function restore_email {
  872. if [[ $RESTORE_APP != 'all' ]]; then
  873. if [[ $RESTORE_APP != 'email' ]]; then
  874. return
  875. fi
  876. fi
  877. if [ -d $USB_MOUNT/backup/mail ]; then
  878. for d in $USB_MOUNT/backup/mail/*/ ; do
  879. USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
  880. if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
  881. if [ ! -d /home/$USERNAME ]; then
  882. ${PROJECT_NAME}-adduser $USERNAME
  883. fi
  884. echo $"Restoring emails for $USERNAME"
  885. restore_directory_from_usb /root/tempmail mail/$USERNAME
  886. if [ ! -d /home/$USERNAME/Maildir ]; then
  887. mkdir /home/$USERNAME/Maildir
  888. fi
  889. tar -xzvf /root/tempmail/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
  890. if [ ! "$?" = "0" ]; then
  891. unmount_drive
  892. exit 927
  893. fi
  894. rm -rf /root/tempmail
  895. fi
  896. done
  897. fi
  898. }
  899. function restore_dlna {
  900. if [[ $RESTORE_APP != 'all' ]]; then
  901. if [[ $RESTORE_APP != 'dlna' ]]; then
  902. return
  903. fi
  904. fi
  905. if [ -d /var/cache/minidlna ]; then
  906. if [ -d $USB_MOUNT/backup/dlna ]; then
  907. echo $"Restoring DLNA cache"
  908. restore_directory_from_usb /root/tempdlna dlna
  909. cp -r /root/tempdlna/var/cache/minidlna/* /var/cache/minidlna/
  910. if [ ! "$?" = "0" ]; then
  911. rm -rf /root/tempdlna
  912. unmount_drive
  913. exit 982
  914. fi
  915. rm -rf /root/tempdlna
  916. fi
  917. fi
  918. }
  919. function restore_voip {
  920. if [[ $RESTORE_APP != 'all' ]]; then
  921. if [[ $RESTORE_APP != 'voip' ]]; then
  922. return
  923. fi
  924. fi
  925. if [ -d $USB_MOUNT/backup/voip ]; then
  926. echo $"Restoring VoIP settings"
  927. restore_directory_from_usb /root/tempvoip voip
  928. cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
  929. if [ ! "$?" = "0" ]; then
  930. rm -rf /root/tempvoip
  931. unmount_drive
  932. exit 3679
  933. fi
  934. cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
  935. if [ ! "$?" = "0" ]; then
  936. rm -rf /root/tempvoip
  937. unmount_drive
  938. exit 3679
  939. fi
  940. cp -f /root/tempvoip/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
  941. if [ ! "$?" = "0" ]; then
  942. rm -rf /root/tempvoip
  943. unmount_drive
  944. exit 276
  945. fi
  946. rm -rf /root/tempvoip
  947. cp /etc/ssl/certs/mumble* /var/lib/mumble-server
  948. cp /etc/ssl/private/mumble* /var/lib/mumble-server
  949. chown -R mumble-server:mumble-server /var/lib/mumble-server
  950. service sipwitch restart
  951. service mumble-server restart
  952. fi
  953. }
  954. function restore_tox {
  955. if [[ $RESTORE_APP != 'all' ]]; then
  956. if [[ $RESTORE_APP != 'tox' ]]; then
  957. return
  958. fi
  959. fi
  960. if [ -d $USB_MOUNT/backup/tox ]; then
  961. echo $"Restoring Tox node settings"
  962. restore_directory_from_usb / tox
  963. if [ ! "$?" = "0" ]; then
  964. unmount_drive
  965. exit 6393
  966. fi
  967. cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
  968. systemctl restart tox-bootstrapd.service
  969. if [ ! "$?" = "0" ]; then
  970. systemctl status tox-bootstrapd.service
  971. unmount_drive
  972. exit 59369
  973. fi
  974. fi
  975. }
  976. function get_restore_app {
  977. if [ ${1} ]; then
  978. if [ ! -d /home/${1} ]; then
  979. RESTORE_APP=${1}
  980. echo $"Restore $RESTORE_APP"
  981. fi
  982. fi
  983. }
  984. get_restore_app ${2}
  985. mount_drive ${1} ${2}
  986. check_backup_exists
  987. check_admin_user
  988. copy_gpg_keys
  989. restore_configuration
  990. same_admin_user
  991. update_domains
  992. restore_mariadb
  993. restore_letsencrypt
  994. restore_tor
  995. restore_mutt_settings
  996. restore_gpg
  997. restore_procmail
  998. restore_spamassassin
  999. restore_admin_readme
  1000. restore_ipfs
  1001. restore_user_ssh_keys
  1002. restore_user_config
  1003. restore_certs
  1004. restore_personal_settings
  1005. restore_mailing_list
  1006. restore_xmpp
  1007. restore_gnu_social
  1008. restore_hubzilla
  1009. restore_rss_reader
  1010. restore_owncloud
  1011. restore_gogs
  1012. restore_wiki
  1013. restore_blog
  1014. restore_cjdns
  1015. restore_email
  1016. restore_dlna
  1017. restore_voip
  1018. restore_tox
  1019. unmount_drive
  1020. echo $"Restore from USB drive is complete. You can now unplug it."
  1021. exit 0