1
0

autopostgresqlbackup.1 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. .\" Automatically generated by Pandoc 2.9.2.1
  2. .\"
  3. .TH "" "" "" "" ""
  4. .hy
  5. .SS NAME
  6. .PP
  7. autopostgresqlbackup \[en] Automated tool to make periodic backups of
  8. databases
  9. .SS SYNOPSIS
  10. .PP
  11. \f[C]autopostgresqlbackup [OPTIONS]\f[R]
  12. .SS DESCRIPTION
  13. .PP
  14. AutoPostgreSQLBackup is a shell script (usually executed from a cron job
  15. or a systemd timer) designed to provide a fully automated tool to make
  16. periodic backups of databases.
  17. .PP
  18. AutoPostgreSQLBackup extract databases into flat files (compressed or
  19. not, encrypted or not) in a daily and/or weekly and/or monthly basis.
  20. .PP
  21. AutoPostgreSQLBackup supports mutliple databases engines (PostgreSQL and
  22. MySQL by now).
  23. .SS OPTIONS
  24. .PP
  25. \f[C]-h\f[R] displays command line help
  26. .PP
  27. \f[C]-d\f[R] Run in debug mode (no mail sent)
  28. .PP
  29. \f[C]-c\f[R] Configuration file or directory (default:
  30. \f[C]/etc/autodbbackup.d/\f[R])
  31. .PP
  32. When a directory is used, the \f[C]*.conf\f[R] files will be processed
  33. sequentially.
  34. It allows one to backup multiple databases servers with distinct
  35. settings :
  36. .IP \[bu] 2
  37. database servers with distinct engines
  38. .IP \[bu] 2
  39. PostgreSQL cluster with instances running on multiple ports
  40. .PP
  41. Note: if no configuration file or directory is passed as argument but
  42. \f[C]/etc/default/autopostgresqlbackup\f[R] exists, it will be used for
  43. backward compatibility.
  44. .SS ENCRYPTION
  45. .PP
  46. Encryption (asymmetric) is now done with GnuPG, you just need to add the
  47. public key (armored or not) you want to encrypt the data to in the file
  48. pointed by the \f[C]ENCRYPTION_PUBLIC_KEY\f[R] configuration setting.
  49. .PP
  50. Export your public key:
  51. .PP
  52. \f[C]gpg --export 0xY0URK3Y1D --output mypubkey.gpg\f[R]
  53. .PP
  54. or
  55. .PP
  56. \f[C]gpg --export --armor 0xY0URK3Y1D --output mypubkey.asc\f[R]
  57. .PP
  58. then copy mypubkey.asc or mypubkey.gpg to the path pointed by the
  59. \f[C]ENCRYPTION_PUBLIC_KEY\f[R] configuration setting and set the
  60. \f[C]ENCRYPTION\f[R] setting to yes.
  61. .SS DECRYPTION
  62. .PP
  63. In order to decrypt a previously encrypted database dump:
  64. .PP
  65. \f[C]gpg --decrypt --output backup.sql.gz backup.sql.gz.enc\f[R]
  66. .SS OPENSSL ENCRYPTION
  67. .PP
  68. Starting from version 2.0 encryption with OpenSSL is no longer supported
  69. as it was discovered[1] (but also known for quite some time[2]) that
  70. encrypting large files with OpenSSL silently fail[3] and that decrypting
  71. these files is close to be impossible[4].
  72. .IP \[bu] 2
  73. [1] https://github.com/k0lter/autopostgresqlbackup/issues/10
  74. .IP \[bu] 2
  75. [2] https://github.com/cytopia/mysqldump-secure/issues/21
  76. .IP \[bu] 2
  77. [3] https://github.com/openssl/openssl/issues/2515
  78. .IP \[bu] 2
  79. [4]\ https://github.com/imreFitos/large_smime_decrypt
  80. .SS CONFIGURATION
  81. .SS MAILADDR
  82. .PP
  83. Email Address to send errors to.
  84. If empty errors are displayed on stdout.
  85. .PP
  86. \f[B]default\f[R]: \f[C]root\f[R]
  87. .SS DBENGINE
  88. .PP
  89. Database engine
  90. .PP
  91. \f[B]default\f[R]: \f[C]postgresql\f[R]
  92. .PP
  93. \f[I]supported values\f[R]: \f[C]postgresql\f[R] or \f[C]mysql\f[R]
  94. .SS USERNAME
  95. .PP
  96. Username to access the database server
  97. .PP
  98. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (empty, the username to use is
  99. automatically defined depending on \f[C]DBENGINE\f[R]:
  100. \f[C]postgres\f[R] for PostgreSQL and \f[C]root\f[R] for MySQL)
  101. .SS SU_USERNAME
  102. .PP
  103. By default, on Debian systems (and maybe others), only
  104. \f[C]postgres\f[R] user is allowed to access PostgreSQL databases
  105. without password.
  106. .PP
  107. In order to dump databases we need to run pg_dump/psql commands as
  108. \f[C]postgres\f[R] with su.
  109. .PP
  110. This setting makes possible to run backups with a substitute user using
  111. \f[C]su\f[R].
  112. If empty, \f[C]su\f[R] usage will be disabled)
  113. .PP
  114. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (empty, not used)
  115. .PP
  116. \f[I]Only while using PostgreSQL database engine\f[R]
  117. .SS PASSWORD
  118. .PP
  119. Password to access then Database server
  120. .PP
  121. While using PostgreSQL database engine, in order to use a password to
  122. connect to database create a file \f[C]\[ti]/.pgpass\f[R] containing a
  123. line like this:
  124. .PP
  125. \f[C]hostname:*:*:dbuser:dbpass\f[R]
  126. .PP
  127. replace \f[C]hostname\f[R] with the value of \f[C]DBHOST\f[R],
  128. \f[C]dbuser\f[R] with the value of \f[C]USERNAME\f[R] and
  129. \f[C]dbpass\f[R] with the password.
  130. .PP
  131. While using MySQL database engine, if password is not set mysqldump will
  132. try to read credentials from \f[C]\[ti]/.my.cnf\f[R] if file exists.
  133. .PP
  134. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (empty)
  135. .SS DBHOST
  136. .PP
  137. Host name (or IP address) of database server.
  138. Use \f[C]localhost\f[R] for socket connection or \f[C]127.0.0.1\f[R] to
  139. force TCP connection.
  140. .PP
  141. \f[B]default\f[R]: \f[C]localhost\f[R]
  142. .SS DBPORT
  143. .PP
  144. Port of database server.
  145. .PP
  146. While using PostgreSQL database engine, it is also used if
  147. \f[C]DBHOST\f[R] is \f[C]localhost\f[R] (socket connection) as socket
  148. name contains port.
  149. .PP
  150. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (empty, the port to use is
  151. automatically defined depending on \f[C]DBENGINE\f[R]: \f[C]5432\f[R]
  152. for PostgreSQL and \f[C]3306\f[R] for MySQL)
  153. .SS DBNAMES
  154. .PP
  155. Explicit list of database(s) names(s) to backup
  156. .PP
  157. If you would like to backup all databases on the server set
  158. \f[C]DBNAMES=\[dq]all\[dq]\f[R].
  159. If set to \f[C]\[dq]all\[dq]\f[R] then any new databases will
  160. automatically be backed up without needing to modify this settings when
  161. a new database is created.
  162. .PP
  163. If the database you want to backup has a space in the name replace the
  164. space by a \f[C]%20\f[R] (\f[C]\[dq]data base\[dq]\f[R] will become
  165. \f[C]\[dq]data%20base\[dq]\f[R]).
  166. .PP
  167. \f[B]default\f[R]: \f[C]all\f[R]
  168. .PP
  169. \f[B]example\f[R]: \f[C]\[dq]users pages user%20data\[dq]\f[R]
  170. .SS DBEXCLUDE
  171. .PP
  172. List of databases to exclude if \f[C]DBNAMES\f[R] is not set to
  173. \f[C]all\f[R].
  174. .PP
  175. \f[B]default\f[R] : \f[C]\[dq]\[dq]\f[R] (empty)
  176. .PP
  177. \f[B]example\f[R]: \f[C]\[dq]pages user%20data\[dq]\f[R]
  178. .SS GLOBALS_OBJECTS
  179. .PP
  180. Virtual database name used to backup global objects (users, roles,
  181. tablespaces).
  182. .PP
  183. \f[B]default\f[R]: \f[C]postgres_globals\f[R]
  184. .PP
  185. \f[I]Only while using PostgreSQL database engine\f[R]
  186. .SS BACKUPDIR
  187. .PP
  188. Backup directory
  189. .PP
  190. \f[B]default\f[R]: \f[C]/var/backups\f[R]
  191. .SS CREATE_DATABASE
  192. .PP
  193. Include or not \f[C]CREATE DATABASE\f[R] statments in dabatbases
  194. backups.
  195. .PP
  196. \f[B]default\f[R]: \f[C]yes\f[R]
  197. .PP
  198. \f[I]supported values\f[R]: \f[C]yes\f[R] or \f[C]no\f[R]
  199. .SS DOWEEKLY
  200. .PP
  201. Which day do you want weekly backups?
  202. (1 to 7 where 1 is Monday).
  203. .PP
  204. When set to 0, weekly backups are disabled.
  205. .PP
  206. \f[B]default\f[R]: \f[C]7\f[R] (Sunday)
  207. .SS DOMONTHLY
  208. .PP
  209. Which day do you want monthly backups?
  210. .PP
  211. When set to 0, monthly backups are disabled.
  212. .PP
  213. \f[B]default\f[R]: \f[C]1\f[R] (first day of the month)
  214. .SS BRDAILY
  215. .PP
  216. Backup retention count for daily backups, older backups are removed.
  217. .PP
  218. \f[B]default\f[R]: \f[C]14\f[R] (14 days)
  219. .SS BRWEEKLY
  220. .PP
  221. Backup retention count for weekly backups, older backups are removed.
  222. .PP
  223. \f[B]default\f[R]: \f[C]5\f[R] (5 weeks)
  224. .SS BRMONTHLY
  225. .PP
  226. Backup retention count for monthly backups, older backups are removed.
  227. .PP
  228. \f[B]default\f[R]: \f[C]12\f[R] (12 months)
  229. .SS COMP
  230. .PP
  231. Compression tool.
  232. It could be gzip, pigz, bzip2, xz, zstd or any compression tool that
  233. supports to read data to be compressed from stdin and outputs them to
  234. stdout).
  235. .PP
  236. If the tool is not in \f[C]${PATH}\f[R], the absolute path can be used.
  237. .PP
  238. \f[B]default\f[R]: \f[C]gzip\f[R]
  239. .SS COMP_OPTS
  240. .PP
  241. Compression tools options to be used with \f[C]COMP\f[R]
  242. .PP
  243. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (empty)
  244. .PP
  245. \f[B]example\f[R]:
  246. \f[C]COMP=\[dq]zstd\[dq] COMP_OPTS=\[dq]-f -c\[dq]\f[R]
  247. .SS PGDUMP
  248. .PP
  249. pg_dump path (relative if present in \f[C]${PATH}\f[R] or absolute)
  250. .PP
  251. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (if empty \f[C]pg_dump\f[R] will
  252. be used)
  253. .PP
  254. \f[I]Only while using PostgreSQL database engine\f[R]
  255. .SS PGDUMPALL
  256. .PP
  257. pg_dumpall path (relative if present in \f[C]${PATH}\f[R] or absolute)
  258. .PP
  259. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (if empty \f[C]pg_dumpall\f[R]
  260. will be used)
  261. .PP
  262. \f[I]Only while using PostgreSQL database engine\f[R]
  263. .SS PGDUMP_OPTS
  264. .PP
  265. Options string for use with pg_dump (see
  266. pg_dump (https://www.postgresql.org/docs/current/app-pgdump.html) manual
  267. page).
  268. .PP
  269. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (empty)
  270. .PP
  271. \f[I]Only while using PostgreSQL database engine\f[R]
  272. .SS PGDUMPALL_OPTS
  273. .PP
  274. Options string for use with pg_dumpall (see
  275. pg_dumpall (https://www.postgresql.org/docs/current/app-pg-dumpall.html)
  276. manual page).
  277. .PP
  278. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (empty)
  279. .PP
  280. \f[I]Only while using PostgreSQL database engine\f[R]
  281. .SS MY
  282. .PP
  283. mysql path (relative if present in \f[C]${PATH}\f[R] or absolute)
  284. .PP
  285. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (if empty \f[C]mysql\f[R] will
  286. be used)
  287. .PP
  288. \f[I]Only while using MySQL database engine\f[R]
  289. .SS MYDUMP
  290. .PP
  291. mysqldump path (relative if present in \f[C]${PATH}\f[R] or absolute)
  292. .PP
  293. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (if empty \f[C]mysqldump\f[R]
  294. will be used)
  295. .PP
  296. \f[I]Only while using MySQL database engine\f[R]
  297. .SS MYDUMP_OPTS
  298. .PP
  299. Options string for use with mysqldump (see
  300. mysqldump (https://dev.mysql.com/doc/refman/8.3/en/mysqldump.html)
  301. manual page).
  302. .PP
  303. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (empty)
  304. .PP
  305. \f[I]Only while using MySQL database engine\f[R]
  306. .SS EXT
  307. .PP
  308. Backup files extension
  309. .PP
  310. \f[B]default\f[R]: \f[C]sql\f[R]
  311. .SS PERM
  312. .PP
  313. Backup files permission
  314. .PP
  315. \f[B]default\f[R]: \f[C]600\f[R]
  316. .SS MIN_DUMP_SIZE
  317. .PP
  318. Minimum size (in bytes) for a dump/file (compressed or not).
  319. File size below this limit will raise a warning.
  320. .PP
  321. \f[B]default\f[R]: \f[C]256\f[R]
  322. .SS ENCRYPTION
  323. .PP
  324. Enable encryption (asymmetric) with GnuPG.
  325. .PP
  326. \f[B]default\f[R]: \f[C]no\f[R]
  327. .PP
  328. \f[I]supported values\f[R]: \f[C]yes\f[R] or \f[C]no\f[R]
  329. .SS ENCRYPTION_PUBLIC_KEY
  330. .PP
  331. Encryption public key (path to the key)
  332. .PP
  333. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (empty)
  334. .SS ENCRYPTION_SUFFIX
  335. .PP
  336. Suffix for encyrpted files
  337. .PP
  338. \f[B]default\f[R]: \f[C].enc\f[R]
  339. .SS PREBACKUP
  340. .PP
  341. Command or script to execute before backups
  342. .PP
  343. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (empty, not used)
  344. .SS POSTBACKUP
  345. .PP
  346. Command or script to execute after backups
  347. .PP
  348. \f[B]default\f[R]: \f[C]\[dq]\[dq]\f[R] (empty, not used)
  349. .SS AUTHORS
  350. .PP
  351. Originally developped by Aaron Axelsen with Friedrich Lobenstock
  352. contributions.
  353. .PP
  354. Almost fully rewritten by Emmanuel Bouthenot (version 2.0 and higher).
  355. .SS LICENSE AND COPYRIGHT
  356. .PP
  357. This program is free software; you can redistribute it and/or modify it
  358. under the terms of the GNU General Public License as published by the
  359. Free Software Foundation; either version 2 of the License, or (at your
  360. option) any later version.
  361. .PP
  362. This program is distributed in the hope that it will be useful, but
  363. WITHOUT ANY WARRANTY; without even the implied warranty of
  364. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  365. See the GNU General Public License for more details.
  366. .SS CONTRIBUTIONS
  367. .PP
  368. Contributions are welcome on the project page:
  369. https://github.com/k0lter/autopostgresqlbackup/pulls
  370. .SS BUGS
  371. .PP
  372. Bug reports are welcome on the project page:
  373. https://github.com/k0lter/autopostgresqlbackup/issues
  374. .SS SEE ALSO
  375. .PP
  376. \f[C]pg_dump\f[R](1), \f[C]pg_dumpall\f[R](1), \f[C]mysqldump\f[R](1)
  377. and the project page https://github.com/k0lter/autopostgresqlbackup/