From 6704565217094402eed32148a9e3e10160c5e35a Mon Sep 17 00:00:00 2001 From: Ryan Toler Date: Fri, 13 Mar 2026 04:02:20 +0000 Subject: [PATCH] restic auto restore --- playbooks/setup-lxc.yaml | 26 +++-- playbooks/vault.yaml | 229 ++++++++++++++++++++------------------- 2 files changed, 136 insertions(+), 119 deletions(-) diff --git a/playbooks/setup-lxc.yaml b/playbooks/setup-lxc.yaml index 43f4955..dd297ed 100644 --- a/playbooks/setup-lxc.yaml +++ b/playbooks/setup-lxc.yaml @@ -7,6 +7,11 @@ vars_files: - ./vault.yaml + vars: + restic_repo: "s3:http://misamisa.duckdns.org:9000/resticbackup" + restore_target_path: "/apps" + # restic_password_value: "Stored in vault" + tasks: - name: Set-debcache.yml - Setup apt proxy debcache ansible.builtin.import_tasks: ./setup-debcache.yaml @@ -25,16 +30,21 @@ - name: Check if app data directory exists stat: - path: "/app/{{ ansible_hostname }}" - register: app_stat + path: "/app/" + register: app_data - - name: Restore Wiapp datakmd Dir - shell: | - restic --password-file /home/restic/.resticpassword -r sftp:misamisa://home/restic/$(hostname) --target / restore latest + - name: Restic restore app data Dir + ansible.builtin.shell: + cmd: "restic restore latest --tag {{ ansible_hostname }} --target {{ restore_target_path }}" + environment: + RESTIC_REPOSITORY: "{{ restic_repo }}" + RESTIC_PASSWORD: "{{ restic_password_value }}" + AWS_ACCESS_KEY_ID: "{{ aws_access_key_id }}" + AWS_SECRET_ACCESS_KEY: "{{ aws_secret_access_key }}" args: - chdir: /home/restic - creates: "/app/{{ ansible_hostname }}" - when: not app_stat.stat.exists or not app_stat.stat.isdir + creates: "/app/data" + + when: not app_data.stat.exists or not app_data.stat.isdir - name: Reload systemd daemon systemd: diff --git a/playbooks/vault.yaml b/playbooks/vault.yaml index ade6ea5..2f481d9 100644 --- a/playbooks/vault.yaml +++ b/playbooks/vault.yaml @@ -1,112 +1,119 @@ $ANSIBLE_VAULT;1.1;AES256 -39633161663666306431656635386139633861376339613338353533336464383833646465303865 -6635393037373136333664303963393736343639653534610a393434623066363230326331303731 -34656562323861663062663266363838633330323363343333356239303833333633303639663833 -3964653130666165340a323238636337373261653530313763306361376233326239656437666364 -62313333306631386266646637633635363036306336613964313530373634306330626233633063 -39643737303938643035316563643635383039343962303137343636383732663161343366666238 -62373435396533353466373139356432303634393161663835633937636662633264313964343136 -32383532643236373937616466303432623833336635656135616166333936333463366533373738 -64346135373539353665333531363832373564303838333935656332346230333130663132633661 -33383137346266373534346433306534376432333566316563643766373762336633613830663730 -36636162373731303462303162353535383031383631323030653161616537326465613463623533 -63623466623665633238626530613331383863656433333832336339323034633736643465663363 -36663432653739306439346263303366363836616539646663643833626634653435656530653431 -65363539383962316430303932373762616132383664353364636635656565373932316634643661 -62643562626433383838373564393164616238316139666166333831386361346539343730363438 -63633733313063313037393733656665303438663335633766396566393038313039336132613735 -61653636356238336637336263643463333531633461626139343530353632343365336433343666 -33356162626161636336626336623866393033393963663864306537326239393665333630653063 -38666636333633386534666332396631376234613463383031663935373431306437366564636634 -62646131666161373439316135373162656161663730306261643337393537626631326631346363 -32386562366263393764623233306464353733383565316335313337366164623739623064616464 -36356535313736636263336563623065356562663261623332383830313934613439343935313565 -65326239343230363037383036383939383233356631333963623634663238646561663664636663 -35626636313762356164323161393834646566623835666663326438383332373030306332393430 -63356537663966633833366437306131663435643334666366333835663164326136393434316631 -61376461336535393333663364323935316165333764613434623763333534626633386635613338 -35373665646238623532323136633932643465616363623135366431376235333463623336636433 -32623237353730333661356535366164363735623237636663353965626462303932316162303133 -65396237646538386136383933613366656134336437343531386135336539353737653734326431 -36393131353339306531363436373462616231613037323737636233626535333134666532343830 -32633161363337663764373437323835366361376361393636353439353736613735386339353632 -63653432323433346332386464363062343766626638623863613833633732393338316437633064 -66396631376237323536373036346333386565363032343862623035333833373631663931356632 -34326139656231373431326337663663643338616235343234363963636438366138393138333866 -64396564666432636439386131333539323739366337633862633035663365346134376132656565 -38623139383766356533333863353034353630353037353664663762336130376662643661393038 -33623933383334373535373562666337323036626135316439333134373161383830636634366638 -33613665363737343339656561643861336437303230386530353536353839386564343836656131 -63366561633737343736353561653330323331393533333238373232376463306461366238643036 -36313835363432373233626633663562306363363434656164616237383664333733323434333765 -64373638383539316131626131336431663337653366653530346338333336373162313730663461 -32653534333932303437653332363536386563623765643563643539613136383135313833373036 -33653233666538636337393265396338393735306332656261636131643164613438613631323531 -38386565363866653237323130363062316133386331333038386332303130383235616234373663 -33333464326563613432653461633834313730653534646466346565336365633733393663356238 -65306237633034613139316135653435323162613835386535366533393234653963353764393830 -66373231313236633830346165616532623861643762363137343831343031353238383866633234 -32333135346135313166653838616334346131393732626334643662326535366634343664383632 -34333034383362366362663765643630623139396534393739316639303739613837323538376666 -65383666373131323337363236343132663232343137356235376230303536323365383165306164 -64363161666366356533386337383830613963666530313264353639323865363936656630303166 -37313861376336363364313638376562613064656632383932346436633461633734303861316139 -37366435636236633039633134343339313433313765653335656165366566653638343361363566 -34346333303931346664646361363532623261323233633131636231323164616636613533313537 -63366630396265353232623436623166633662393037356262623331303233383437316361356134 -30313436633335393135326633653265333432366639333338326539643137326533393637623633 -30323332356363656439393933376562363139303735353765623030643936663437326330376431 -37393936613534313033353465343033346333356634343335656538383065373336353632663161 -30613534383133346338366634343436663862386464633864646336323030373231636464323036 -39633861636236326632373132633439373831343734613936666639613336356639306231643361 -37633864313166396632396564623063383332343634386334366532626637346263306665353833 -62313233356432326561343766303833626433363131323931386666343337633732626339636164 -33636636666630326639356134363633636465623139663562383761613235633764366634656664 -39353935643832333463646238383761383061393938303134353863346161323937623562386161 -35663861353562303063653635636231346235613731346439313664666639363632316131663966 -36383763373431666163303634343631356263393533656231383032653831393432373365626130 -63386334363735376238616664653538376134353839663535393031633131363333623062346136 -63316131653861613362633633363632633834386662316438313962326539653264623033346663 -39663266313333326137393663383563383936366465656333663561643831666265353637623739 -32393238663731383664323432656365613433623761393733353538316466666166646439343637 -62393533376264356135313036646432323731366362333661326437316234396533353737626532 -62333961626130633663393136313466336163393163383464643336366365376334343766353635 -64666239663532616336363035346437376362633661636566386566396430663965626566356663 -61653362336234363736646536623034633731313337366639316135346665363866626561656138 -38343166316265633935366263636137613238653038656439636663663934363363353034323661 -35333730303830343738663135653637376239633232333363373237643437363135323532633462 -62613363386563306430393237623566623264333936623132313364333539653038666262303865 -63386165366364383364343039306666616261323562663733653732656665616361623838313538 -64376664343133353433636235643365333262656539613861353030646364376461313531316132 -32613530393734313065383832313765623734633339643333396133306663653333363731356237 -31326234383339386235623538316366363262393833656634316432663932303263366537373464 -62646337366334616466316636386462376335323031373339336139343334366131653539616461 -62383139613236353361373961363265373933393139363765323733356436386265303131643265 -33346536353239363430343664353132653864333236383034333462633139343133353864656138 -39626263663536633266623161336365663335343230333364633664353939333763356537303738 -35623336626232356265363534613438306662386364356233626261313634323466663766353438 -38636632373237663132636263326364653265336366326530323331666363646361386564343434 -61646561386264363062363934306330323631343530323932616363373830323037373265313032 -39356365663061656137643732303436666536653063353432393736653038306630333239643434 -30353962313432343935353062343530663161636632653062316536366165323235663661393133 -65366334363062323063333461343138326363376236363037333965373931396261356561373238 -61616134383232306364303461383466393631626565323530633034353766653033313865326665 -61346433353435666236303333656464643734326566643262633464376431313430646263393263 -36343335323730643166633664613833376131643539383135373466343530306262326364653361 -65643365623936646530613062393261643361663839653664336631646435316634336638666466 -39333632626532613830373931316664613431363764346330663761616338346464353239613364 -35363937643239623963323631343136323533353362383439383438636561666663356237613132 -63646536366435656362383033316133626266666663633265383336623730646336636633623238 -39633231323261646630376337336664376566316162346135303963336431623431663061636537 -61643837396364313464663633613935636231393636623763616162323263316134623362633035 -66373466353335633463316562646363653738643235613632323233316437313038383463353861 -38636633333038363735313037363433363964363630366663396166386465666661333763656664 -62376462366264363132323330663838323337373166616336303738373033353836653731323064 -34623965646236613131353831383765336564343834336538373630386533393735646330623036 -36643633396433323565613265393336663137643965383463656564366230613332383635326233 -37636531333563626131643132386666336631653766623131663337373163633865663766323065 -30386139343836396137326632333661663039336433663965623036666662653437383531643632 -36316665303231333933323535356335636434646164336538353832373561366630386666666134 -34393734306230616634366633623438306663363530346262306337313864363937346461363664 -30306132653763663566313130393736646133313733316262393461626563323162363732373661 -303066396331643535393634313030663634 \ No newline at end of file +36356234343834313339326636393736343230393939393735663061343832346433393665646130 +6639386164656231626530376235393165343731636564630a303133323832653730303735326662 +35386139373638666632386535326165623566353131343030613033363763363533313632396665 +3161633161336364360a316331303235653638303134336130323730346336323735633435336537 +38636633303461643637653335633236316633313265643064323066373561396237353738623638 +32323930386534373234393030653666306635653234643464633733363231303861346566336138 +34323366316239626365393231353666363136633262396262383833633938376164386232373264 +37636364646332303664643231326236633236626634366638613462653462656664343934343234 +34363332666366333036373034303263333533323932623261623235613332353737336538303361 +35626666636362356230383265366136306637363131303662376666353239333838393631376130 +36343230303866396539646139326536306238333066656366623262303837333931656261336533 +30653963373435326432613562636636663633653738353131346164363061356639663538653135 +65383162396464333331653961386365343439363534363237366239323635636165363532623032 +36326666656130333061643434393763386466643465313235333736373961366530626138653339 +30373836353834656561373634656531366235383335663333353465326162393064343138376439 +38633866636365643736306164666562613361616664653835346561346163336633303030366631 +31636435663764363663313538373237343765376334303161653365383537393463643830303437 +31373761636366393039623536393736386536323366653364336462636134306662336565343962 +37653638393739643738663238393866343132636438313332666131366635306233353031643737 +64643137353938613139613631633261353037323036356638336664336338333533393230613361 +63646631633731326437313265353534383232346635396636353630643438386538373431666662 +62373534393564653762353837646363363334653038383164346366316233306362363032373162 +62626462356334393830346230666130343030363639343766653663623764636364666433643663 +36313065656662613634306135303732353264643466353630393831333765336238633539666238 +30623937393835393264616539653530346362663164323134653663613138353336383836346537 +62326530306239616635383734333637326532373230666562336565643163633464613230353064 +66303433633735616262616235316231616664613730623534636566353964653461393039393537 +65616364653638303630323662653231336135393330646536393262383966613466326663336333 +36316334626133626665313735626136613838386437326262383963323634393132353263323431 +63336331343636633631623939346237366365663832323234383262313835373561633933306633 +38646663333035333166653237396139383061373538353462646463666463333466623066326362 +62393363613131633564353365326238303238333963383633313131386661306638383931306436 +31396564653533616231383332393566376237353634616564396164663435313464373938313266 +38623638353438356563343038333835363130653139313066613434383637313938663961356637 +36366464333666356632383039353961656632366363336364333533656135373464313334643262 +38343431386232303965663562653063666631653765316538383631633963353335303234616332 +35663034663230343030636638636436653534346638353730323032383363363164343530333937 +32303632363435306262396364633230653062376330633630376331336336633532616530396661 +65643538393230393834393839653432636339306462333566313564383231313736303661656662 +61316362373733383939663236343136663365383239316564323963363532616139303734333566 +66333139343131336533323461363366353965393731613935363466383463383331636361343230 +62373335323738653233303062336134363234303938313063333135616335643030346338643634 +66373533623034386461393037313739626135633738653039386263396439666635663333613863 +37333437663837623032343261323435626232346262363631353232643462326561616138343133 +36343437643162336237393365363364366164363563343733643265346633663761313030363536 +66326431323563353731613637386336626462623634353335346135343435326630393939633736 +39616532303832346635353531383633393663333966643230646435363461313839373666343632 +33363836663034613561663332663362323835303365343633326163613632376132323035646630 +63333936643731316637613135373634393035643238653561633734363937333035386435393236 +61336131626666373464343866666136356231636462303136343164323137376363326636353239 +63383337316134316438663237353065666136343632333062393634633761373339363866353563 +66333736356435383232343939313139383764643233613964363330336233663834346630366462 +62363234643132383432343131633365326462376639363333623964656139386561633637353565 +36386466343965623731616566643366333564326331636662633836666234646162613430343138 +35313131343262663534616162663463343431313930633561343666643435373264393739313134 +35373231383634646136376135646333643466363739376439373466323962653361323437333666 +37616534363236333766323866616666613265646234393766373163386266393137333534383036 +32616164353931353639633165343233373366396132656432393366626236306434306234343630 +39646333383637626636303164396230323763373330623135303238346465316365313533656339 +30346665376362633634623332346565666136643035306330393262393531313133616535313763 +63353831626663623861326565323136633366363464336430303133346432353438396230666438 +63386463303034363639666136326233356361613736363834646466386165336139363539656135 +33323165643765356265363933653763376663653439326230316439393566643731616633643862 +37363166376531626230383632393966643366366338303638613532333537636536396235356265 +39396337643431396164363139313431303932646464613137303532653765653361343536353534 +64313935346530333233616661333936376234353735353637643461363461303336633062326136 +65663033643864366234326563643434386433663033306438653233613562386138663264646639 +66303734376430366530366163383732633339383365306464633333393164343431326564383966 +36323736323639313462346239363163343538353438653366366137396234393438643634383433 +38613738653332646363386433646565616330656361636533663164653265316631653638613031 +61366339653962333866616235656361373163376466333439313633343734666431626462326235 +61376238626537386335383437663732656564643832346535373934613764356430333430323366 +34393532383733343364633437366564656232363738336435363664303631346436636532666366 +36336537376534313934393636373731316636336565633766326362356338306666343736636334 +36336363383931636630303737363631393334383933346631353434613366633363613536393963 +61303536346164653038336131316262303566346339336166306436313364616431326138353462 +61353762353632613464613537613063343834643036646131323036616335626631323036643366 +61613134363664613235306438613638343162346466386135303061643332653534373635323461 +32626662623037613066636637386639373638323064363335353637623462396562366630333939 +31376631633138343730336265363338613466623464333931353966623766356336316230306530 +34663565623362343065626131326539303937363732666239326439663963353935366663616232 +33363130656365363032623132323863633964353533313339373730646163613934313934366565 +36356436343665353636323938316664636433393064353535653461366264343664333737613733 +61326564336631313164383163663833393365653365643535633631346336393466396631326564 +35353734306631326566363132616263346135323762363031383363646439383230326630363134 +39396134663766393364633236616562393131623365333538376263313764666261613131666462 +39616363343166316161323634363936623861623136363166646262326564333062323333383432 +34343732386166613034363265333633383533393937626235653038616332366439616336656432 +33366139353862633065363037346131303661326264336432346664336235616137373063643961 +37323565666337383035636662633937366138343464376337323364313761623433396130303634 +36326531366264363031366161363466393565383435363235366262623331626635313665353236 +36323263396461363735396138393639613963633235616333623263396432353233306231353338 +62373036326432623762396334656636643365636533386430633062346439373533613163313463 +33306534366334323535613331643935393836363962636539666661316436616236383135306264 +33363734373664623434623539313937643061383535303932376132616433313335656331653736 +34303438333066346632323565646431313063363534626562646663346363333963643563663731 +61303362306332616631313336393065396563396465386332363366363962316663643137303265 +31356666653434303538363635666638323831386439643662346230623964643233356165366230 +35626662336164663964633731343336316535353937346231643862356239623935666236306363 +32373761626466366363393863323866653534356162326639633430613531363339303132383630 +34643536646161643634316632653166633339386430393439393131346335663261316332323961 +62636333306566383339323233363437363062643762306262353263616563353337616135383661 +38663564393532306161343666343233363634373064653539386562303734653930653534633463 +38363035653931636138653936666362343739613032393034323162316433623736663136346138 +37663938626261666531346530613538633061643238373135303461393162363366613365633366 +36613461306438633161656665386433613063343063633966363936313764333564336338636432 +38646633373038663930343937656162376639386237366361303336343563326534666238383334 +36323133386637303235316462316431613831343533643266303164616537373931323865643563 +61666362393061636163343665333866336363633037323264356430383936346634663063666463 +32646163393132613236613931666131623737383266356539666464623732663864303735613565 +37646365316438306336336539306531646262383466316330663032343666633235303233656630 +37343632343134323030383431613839323834346236386662393532303065343866366138346333 +34356138363435353432383731396230343034303033663937623062613736616662326566353634 +32653563323762653933343430383664383838383364666161356431396161353666383732326164 +38666234376565626137613932653264313964616635656335613537653136313765623239343138 +66623162663831303462316232333365613335613963323365303463353339336339396638626264 +37623831646133383230393833316638396166653037376232633035373362646463653130313961 +6366313864373061396336323331326632646665633333383537