changed the logrotate process, cause it did not work

This commit is contained in:
LUXEY Adrien 2020-07-13 11:36:23 +02:00
parent 6742104999
commit ed00e2793d
3 changed files with 156 additions and 118 deletions

View File

@ -78,6 +78,26 @@ TODO: Ansible task to install that before the rest
## Misc
### Creating and rotating backups using `logrotate`
This is quite cool because `logrotate` manages rotation/deletion of 'log' files very well, so why not use it to rotate backup archives?
One can also add `prerotate`/`postrotate` scripts to a `logrotate` block, which allows to create the backups using `logrotate` too! (This way, there is only one utility taking care of the full backup creation/rotation/deletion process.)
A problem is that **`logrotate` blocks won't run if the block's file does not exist**. So, if you create a block like so:
/path/to/backup/dir/db-backup.sql.gz {
prerotate
# create the backup file
endscript
weekly
missingok
nocompress
nocreate
}
This block will never run unless `/path/to/backup/dir/db-backup.sql.gz` exists. This is why `roles/build/tasks/backup.yml` creates an empty backup file while defining the logrotate entry.
### Synapse
Someone advised me to install matrix-media-repo to enable animated thumbnails as people's avatar (https://github.com/turt2live/matrix-media-repo/blob/master/config.sample.yaml#L394), and to setup https://github.com/ma1uta/ma1sd which is a federated identity server.

View File

@ -1,62 +1,62 @@
$ANSIBLE_VAULT;1.1;AES256
38303931663431313139303564643632346430303831653566633335313766613265373438356530
3939313366336534663066396337313330623739383661610a623862336361653066626139663830
33363064643635316235336635333034373166306138353833643333613766663038376262353061
3864306462613435390a336337643464653638623336643036303261363865343738636134303566
66366230303037393865303537613035303764343766316166326635326330326633373132613865
39323232333533626632343339666462323864653336663064343062323131396433323534363837
66396562636561663935373631666337343035306539613335613233343732383137316362353034
36303734356337636262653837653232303264393031396236303963383336333336313439333562
30663064366461316637373230633934343536646337623134326631366366383165623739626666
33326462353838306137376632646661636236356239366366396238393764643563356532373133
39353465303530366264326363653233326138346533613338376439616537386134363062356564
35626361303634366161303432636536396338336464323365343233346264363239343336643933
39333632393334613835343337346633383966363064656539326630343165653663643965393862
31363332386262313238373436643136346130396538353631343137353032386164393535346534
63636565303738623333663238646661643931366434663237396135613830306366373165353562
36623262316539613161383737323135646434386330386331326336313462643133613234336537
64333535613662363165363237313263323835323137633166643339303633383139643038376266
33613538343666626466633832363163366337646466356434323431396462663933333566356432
65363930623863333036383537366439316537663239666339303434303033653133383939393762
39653561333334343531343765303235623262396539636361313039646132656433356538633363
64363130643365303964663939393963616263333766303433356637346137386434313237633932
62643063646234376637323934623336666464386334653062373431386363353065323065373038
34326637366231353930333236336133393762633963383464363139343137653330386664663161
64663636356262643566653132376233376233326237346130646462373761646361646662653030
39626331636339303437396162613165623163373762316136623236393733643532333532366166
66343734396636623066353636366363653630616464353062313837393635396232356465343335
32323661653362343866316233623032663736643234626161663330316632653539616337663365
33393636376639383632376262653836376639326566346461626363636563653534323432323239
31383337613237653637303137363633323138653937373333393165373065623963363066636339
66313966613738343939613064383831383862383465666230303133383039626138373837313830
39333235333438383230306438323364343736643339393432653338646563393965326561613063
37393932653233316434346630653065316162613466626664376165376562333466363034346331
35356163336663323637303639313461623939616338663735663538633234623136393665616238
38366130363735393833316134393435313339326539663839653039623033326130386363346366
35373336333763323734343466393464336136323364633934396164623837353163313936356664
39303633616337373265333265326531346238303464323066373436386536306433376561633837
36316263643935626162373066613133616563326139346461383531633534383365663962343231
30343636376661313730623036323164303661623765626637653434303536643134653538663837
33333638636332663131313532323836646238623963653937343635653262343537336531656161
32326162653234636539646462613066336138636530303937343037333066396236343061366564
66646637353839383664666265336434336163323335663932316565326235343861313862353036
62363136633765643365353462323139343932386430623665353139313964353031363133326137
62396437336564646332343031333339313830343236313334666533356233353265376366376531
63336234353136386137333666366162326431353165633832346439383030313433636661366237
35386263363532316435633737663030383762633234613530663636333262396232323635333066
39346333386535323863393134303965303539373635336465326261306664613735323033383362
62666566613563383732313963623063663261663664653764313631386237303062643032666436
39656235383633356365653835316164393632363331643838323463393432663831316431643632
62303765323332366138323038656264353237366232656165323264663836656637383063666461
39623861623166613566663965643033316661336266643334393763623036336664386133336635
34396639623634303061303966623366343530646161306231343634306530663432613239396338
66643336366439306164303532383938373133363938356138306665366535393464636139626561
63313236353536646563656264346564333735643462643439633933373665656435386565396365
37313237396239356134393661303065316266316537666431313634623561383634303061613066
63383531366237663734653935386265313563326161393132373130393663663564313838383335
64366563366635316436363238623633396132666165373036336230653839353561646365303333
62376532396265373936343234353866313636633130353465623335313236336432343433663733
63326536356339383332313437653565356266396262643166666561363564396361666339366165
31376632663730356337316238356665323161396337393233646563383363613433333738663964
66303762626666646261346239383961346465313862363563643434363963376534346362376463
32326165646232386332373533633435383538613137653034626231383464636230
34313230623935333063313264653437306564333937353565333335656536633665376535353131
3138663538646433326532653736353437316435613839350a353433383163346239303535333138
30333737333263626663323738656137616536313630316361353539633862383839373261366562
3338343636303235330a626466666162383237376664333234373463326530376635643264336461
65626463316437636364323137613863616461633436626330336139643437363637333137643132
37336536373963323439323333333839633366663137646231333736623535633465613664306665
62333465363936666465663064363837613364636635633863663436303835653335653266373465
64316436343864383433643361323733656366336563396232343732383330653835386564373466
32643030353632323464383037343165646264396534656164383664383832653938646461376237
61623462393437313661323832626237383330383932643330363365303234613666316433343465
37336434303138343062343566666539626664613136383537323437356339386463643632343236
64663362623933646131616661356336376535343466656233623935363938393965653266363563
32303638623832663535396438653233356134646533623362383138303265393864326665336531
63336136343637363764323062386563616134663131346532333631373337326664643938646363
63333730653339356264363365363736636262363334633736303134303639643338393735346363
33666661313066393635613263663737376265656531343033323538633265393666363764643361
66633530346463393936383562353134343263643963306332393961663333363537666339643333
61346330616564373438643137626563353136643066636665356136393530643633393130373331
30306464633565336335623637323531326630313331326266653236313166643139366335626137
65616138353332373935306436326466306331643134316362643330373564366633346639643536
38633938333633333165643662353166666362646234646633633662366533393634376363396138
37343865313263653036346233653165643235356632373866343934633738653763633634333433
33303834656664323861316438646135343865333363313265303532623866333035643736613935
36323563386433303062623635393633306362393964376336316634623838623166653837646236
37653166653231386439316136633664303131646539656335303937343936653062303664316239
38383364323261663766653835386162646630373163613634326462366334393834353161353138
30633035303635646436343264343064636265303534653335363835653535653731613730353631
66643138633833346462313466376137343432356131333630356238326366383932373739623133
61336466393730653839623930303762386230646439363139636334613939326161333135306434
36643565346663643665316537646232376164326464313038616462366231323561653934356139
61366665646534313435363234626233613735633466316538663633353132623832643166363938
34356562653564656334623437376665363530363636643265633831343862363033356433363036
61346532313339313530633038346230316232623663613731613734393630376166353436626130
34666264383832643331636635336436313965363561643331653730303364626462636532363131
62623966356165343032386531326232636661376130643065316633333162303063633432373433
38393139613462623661333534396431663534376534366439376666313735323963613333663737
65623863323733366136313132666363616566363236366334323265306662366639373339373838
35373132313661313134313831643334353934303936393139326161316134616266643233386135
66613235313336326666643961306563393037366538323136346564386132326166326431313338
33346662353138373032333733613538383037333531316631636134633733316134383066346139
38643033313631646465306537643935666233623561626262393463623132336461343833376330
38636631386536373631366562323438303932396161343238313965396266376262636463643361
39663666613334666165363038656662616435326162636133316561343034393561393465326230
30386435643832613931646533633231653431376165653564386563316331376138393664333238
36316465373661303438616462643635623138633737626438323535383737323061366637616336
32366265333931313234306230383565313130326333303638306436626333613866643632396139
36633931333436343764353432376435656332396463303838316132383161363835353266646537
39363033326139326433623237386337313763373264643233323237643239623666346337343233
35366332396264613433656462663332363337643866626638393537643437363537623633633932
32323463343035666462366231353965376562303235343964633038653864373134383364313533
63336636663764333037663233643861303237336462626635636139643839646363623562653961
38613562613433363539636331646564646430346432646236383530666536353562323364313466
65373332656637373831656336646632333464636335376232636262353432326637646432643561
30313433646537363136363465646538643166343337326539343634303439636235383735303965
64376634613731323430303231373062333233366561666436326535646262366539373031353566
65393065653466326266666365373239666233356666393866383933663261343166393232393865
62376161663065303663653633383431653932323663376563656464616336656465393734613161
32663566656238353732366230343662343931366236383632613732303133313339333335633666
63666266393766306463393166313036303032396565373266636462653461333062346137623365
61313465333666353138303261393461393134313639353763323766633032356133356633356661
39643362366137376439383063323230343435306330306633633737383833393739

View File

@ -5,70 +5,88 @@
- name: "Setup periodic site files backup"
blockinfile:
path: "/etc/logrotate.d/{{ site.slug }}"
marker: "# {mark} DATA BACKUP"
create: yes
block: |
{{ backups_path }}/{{ site.slug }}.tar.gz {
prerotate
tar czf {{ backups_path }}/{{ site.slug }}.tar.gz {{ site_data_path }}
endscript
weekly
rotate 4
nocompress
dateext
dateformat _%Y-%m-%d
extension .tar.gz
missingok
su www-data www-data
nocreate
}
block:
- name: "Create logrotate configuration"
blockinfile:
path: "/etc/logrotate.d/{{ site.slug }}"
marker: "# {mark} DATA BACKUP"
create: yes
block: |
{{ backups_path }}/{{ site.slug }}.tar.gz {
prerotate
tar czf {{ backups_path }}/{{ site.slug }}.tar.gz {{ site_data_path }}
endscript
weekly
rotate 4
nocompress
dateext
dateformat _%Y-%m-%d
extension .tar.gz
missingok
su www-data www-data
}
- name: "Touch empty backup file"
file:
path: "{{ backups_path }}/{{ site.slug }}.tar.gz"
mode: "0644"
state: touch
become: yes
when: site_data_path is defined
- name: "Setup periodic MySQL database backup"
blockinfile:
path: "/etc/logrotate.d/{{ site.slug }}"
marker: "# {mark} DATABASE BACKUP"
create: yes
block: |
{{ backups_path }}/{{ site.slug }}.sql.gz {
prerotate
mysqldump {{ site.mysql_database }} | gzip -c > {{ backups_path }}/{{ site.slug }}.sql.gz
endscript
weekly
rotate 4
nocompress
dateext
dateformat _%Y-%m-%d
extension .sql.gz
missingok
su www-data www-data
nocreate
}
block:
- name: "Create logrotate configuration"
blockinfile:
path: "/etc/logrotate.d/{{ site.slug }}"
marker: "# {mark} DATABASE BACKUP"
create: yes
block: |
{{ backups_path }}/{{ site.slug }}.sql.gz {
firstaction
mysqldump {{ site.mysql_database }} | gzip -c > {{ backups_path }}/{{ site.slug }}.sql.gz
endscript
weekly
rotate 4
nocompress
dateext
dateformat _%Y-%m-%d
extension .sql.gz
missingok
su www-data www-data
}
- name: "Touch empty backup file"
file:
path: "{{ backups_path }}/{{ site.slug }}.sql.gz"
mode: "0644"
state: touch
become: yes
when: site.mysql_database is defined
- name: "Setup periodic PostgreSQL database backup"
blockinfile:
path: "/etc/logrotate.d/{{ site.slug }}"
marker: "# {mark} DATABASE BACKUP"
create: yes
block: |
{{ backups_path }}/{{ site.slug }}.sql.gz {
prerotate
sudo -u postgres pg_dump {{ site.postgres_database }} | gzip -c > {{ backups_path }}/{{ site.slug }}.sql.gz
endscript
weekly
rotate 4
nocompress
dateext
dateformat _%Y-%m-%d
extension .sql.gz
missingok
su www-data www-data
nocreate
}
block:
- name: "Create logrotate configuration"
blockinfile:
path: "/etc/logrotate.d/{{ site.slug }}"
marker: "# {mark} DATABASE BACKUP"
create: yes
block: |
{{ backups_path }}/{{ site.slug }}.sql.gz {
firstaction
sudo -u postgres pg_dump {{ site.postgres_database }} | gzip -c > {{ backups_path }}/{{ site.slug }}.sql.gz
endscript
weekly
rotate 4
nocompress
dateext
dateformat _%Y-%m-%d
extension .sql.gz
missingok
su www-data www-data
}
- name: "Touch empty backup file"
file:
path: "{{ backups_path }}/{{ site.slug }}.sql.gz"
mode: "0644"
state: touch
become: yes
when: site.postgres_database is defined