Merging Watari-Ansible and Homelab-Backups

This commit is contained in:
tolerryan
2026-07-28 00:28:35 +00:00
parent 3eef168b17
commit b460cf8d6b
12 changed files with 842 additions and 126 deletions

View File

@@ -1 +1,418 @@
firstrun ## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
*.env
*.code-workspace
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
*.vault_pass
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
[Aa][Rr][Mm]64[Ee][Cc]/
bld/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Build results on 'Bin' directories
**/[Bb]in/*
# Uncomment if you have tasks that rely on *.refresh files to move binaries
# (https://github.com/github/gitignore/pull/3736)
#!**/[Bb]in/*.refresh
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
*.trx
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Approval Tests result files
*.received.*
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.idb
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
# but not Directory.Build.rsp, as it configures directory-level build defaults
!Directory.Build.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
**/.paket/paket.exe
paket-files/
# FAKE - F# Make
**/.fake/
# CodeRush personal settings
**/.cr/personal
# Python Tools for Visual Studio (PTVS)
**/__pycache__/
*.pyc
# Cake - Uncomment if you are using it
#tools/**
#!tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
MSBuild_Logs/
# AWS SAM Build and Temporary Artifacts folder
.aws-sam
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
**/.mfractor/
# Local History for Visual Studio
**/.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
**/.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp

0
.lock Normal file
View File

5
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"recommendations": [
"redhat.ansible"
]
}

View File

@@ -1,3 +1,4 @@
{ {
"ansible.python.interpreterPath": "/usr/bin/python3" "ansible.python.interpreterPath": "/bin/python3",
"ansibleVaultInline.keyfile": "~/.vault_pass",
} }

8
ConnectionTest.yaml Normal file
View File

@@ -0,0 +1,8 @@
---
- hosts: all
gather_facts: false
tasks:
- name: Verify host connectivity
ansible.builtin.ping:
delegate_to: "{{ inventory_hostname }}"
delegate_facts: true

View File

@@ -0,0 +1,16 @@
all:
vars:
ansible_user: ansible
children:
app_data:
hosts:
semaphore:
ansible_host: 192.168.0.62
app_docker:
hosts:
semaphore:
ansible_host: 192.168.0.62
home_grail:
hosts:
#grailbox:
#ansible_host: 10.0.1.31

23
group_vars/all/vault.yml Normal file
View File

@@ -0,0 +1,23 @@
# Values do not need to be quoted, use ctrl+shift+/ to enmcrypt/decrypt
vault_restic_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
32383930343833656363333238306366626430383939653262316637623339646264653830653237
6539353761626230376463633839383335613434336130340a663136616438356235633535346138
33343364646637623139346235633035386365643565303431623132376666616334363436316363
3339306166343366660a386135663031616362306637616334343830633332626637626534323663
38646561366538323864623131653464393338363563303337383363353232343433
vault_aws_access_key_id: !vault |
$ANSIBLE_VAULT;1.1;AES256
31633166363961666131636236646433323162373530353031383734316636333330326530393736
3136653133396464343134373233646537383236383362340a393439623939376361356162376265
31393261633630376263613139363936393966356334633133643965303731373832666535626331
6636383962356131390a366533383132643031376262633437376464623262303137373164643030
62613863303235336335643531313464373666333730326264376561393739663539
vault_aws_secret_access_key: !vault |
$ANSIBLE_VAULT;1.1;AES256
61663563303730666436313566656238336333643439373132393634633731633866643432656334
3930336332633734633734666564366235633630653635620a623239333661396562383864373530
65393533626537313131353639323765333232396665303938323565653163396236306664326166
3730666339643962390a313065616663336639373337663536623837633330393733343032636139
38623639346563323364326532303064636233653733373761663364353436353231306131343834
3763393666323133353565396633336131373566353466373634

32
inventory.yaml Normal file
View File

@@ -0,0 +1,32 @@
---
# Basic group structure
# to avoid / for paths just using words_ ie /data = root_data
# ALL new paths should be added as childen at the bottom. this will allow 1 task to run all backups.
all:
vars:
ansible_user: 'ansible'
children:
app_data:
hosts:
semaphore:
ansible_host: 192.168.0.62
# Add your other data servers here:
# server2:
# ansible_host: 192.168.0.63
# Maps to the /app/docker/ path in the playbook
app_docker:
hosts:
semaphore:
ansible_host: 192.168.0.62
# Add your other docker servers here:
# server3:
# ansible_host: 192.168.0.64
# Maps to the /home/grail/ path in the playbook
home_grail:
hosts:
# Add your grail servers here if any:
# server4:
# ansible_host: 192.168.0.65

View File

@@ -79,15 +79,18 @@
dest: /etc/systemd/system/app.service dest: /etc/systemd/system/app.service
content: | content: |
[Unit] [Unit]
Description={{ ansible_hostname }} Description=App Service
After=network.target After=network.target docker.service
Requires=docker.service
[Service] [Service]
Type=oneshot
RemainAfterExit=yes
User=docker User=docker
WorkingDirectory=/apps/docker WorkingDirectory=/apps/docker
ExecStart=/usr/bin/docker compose -f docker-compose.yml up -d ExecStart=/usr/bin/docker compose -f docker-compose.yml up -d
ExecStop=/usr/bin/docker compose -f docker-compose.yml down -d ExecStop=/usr/bin/docker compose -f docker-compose.yml down
Restart=always TimeoutStartSec=0
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
@@ -95,6 +98,26 @@
group: root group: root
mode: '0644' mode: '0644'
- name: Setup App upgrade Service
copy:
dest: /etc/systemd/system/app-upgrade.service
content: |
# /etc/systemd/system/app-upgrade.service
[Unit]
Description=App upgrade
After=network.target docker.service
Requires=docker.service
[Service]
Type=oneshot
User=docker
WorkingDirectory=/apps/docker
ExecStart=/usr/bin/docker compose -f docker-compose.yml pull
ExecStart=/usr/bin/docker compose -f docker-compose.yml up -d
owner: root
group: root
mode: '0644'
- name: Start Docker service - name: Start Docker service
systemd: systemd:
name: docker name: docker

View File

@@ -1,119 +1,46 @@
$ANSIBLE_VAULT;1.1;AES256 ---
36356234343834313339326636393736343230393939393735663061343832346433393665646130 ansible_become_password: o#k!7k#Y3Z77#v
6639386164656231626530376235393165343731636564630a303133323832653730303735326662 docker_priv: |
35386139373638666632386535326165623566353131343030613033363763363533313632396665 -----BEGIN OPENSSH PRIVATE KEY-----
3161633161336364360a316331303235653638303134336130323730346336323735633435336537 b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
38636633303461643637653335633236316633313265643064323066373561396237353738623638 QyNTUxOQAAACADSWp6DwHwFCAToFhEYDhcrMI3+cIi1pUTfmB9EhQ8qwAAAJhT/0qEU/9K
32323930386534373234393030653666306635653234643464633733363231303861346566336138 hAAAAAtzc2gtZWQyNTUxOQAAACADSWp6DwHwFCAToFhEYDhcrMI3+cIi1pUTfmB9EhQ8qw
34323366316239626365393231353666363136633262396262383833633938376164386232373264 AAAEDU2IdypnIdt3AECWtnP9si57GJ5NGUsIC63HY2nbXtRwNJanoPAfAUIBOgWERgOFys
37636364646332303664643231326236633236626634366638613462653462656664343934343234 wjf5wiLWlRN+YH0SFDyrAAAAFGRvY2tlckBob21lbGFiLmxvY2FsAQ==
34363332666366333036373034303263333533323932623261623235613332353737336538303361 -----END OPENSSH PRIVATE KEY-----
35626666636362356230383265366136306637363131303662376666353239333838393631376130 restic_private: |
36343230303866396539646139326536306238333066656366623262303837333931656261336533 -----BEGIN OPENSSH PRIVATE KEY-----
30653963373435326432613562636636663633653738353131346164363061356639663538653135 b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
65383162396464333331653961386365343439363534363237366239323635636165363532623032 QyNTUxOQAAACDrAyK1ekCDLaSRTaWRIB55GIBQujlzCUBXNSaq56Qs2AAAAJi9rDmEvaw5
36326666656130333061643434393763386466643465313235333736373961366530626138653339 hAAAAAtzc2gtZWQyNTUxOQAAACDrAyK1ekCDLaSRTaWRIB55GIBQujlzCUBXNSaq56Qs2A
30373836353834656561373634656531366235383335663333353465326162393064343138376439 AAAEBBL4+EMlH5jWEUbwAVwVYsg0Dr/B/XT927FCElWguIMOsDIrV6QIMtpJFNpZEgHnkY
38633866636365643736306164666562613361616664653835346561346163336633303030366631 gFC6OXMJQFc1JqrnpCzYAAAADnJ5YW5AbXhEZXNrdG9wAQIDBAUGBw==
31636435663764363663313538373237343765376334303161653365383537393463643830303437 -----END OPENSSH PRIVATE KEY-----
31373761636366393039623536393736386536323366653364336462636134306662336565343962 restic_repopass: mLDecjbubXG5Nw1PdSeGbW45f
37653638393739643738663238393866343132636438313332666131366635306233353031643737 discord_webhook: |
64643137353938613139613631633261353037323036356638336664336338333533393230613361 #!/bin/bash
63646631633731326437313265353534383232346635396636353630643438386538373431666662
62373534393564653762353837646363363334653038383164346366316233306362363032373162 # Variables
62626462356334393830346230666130343030363639343766653663623764636364666433643663 WEBHOOK_URL='https://discord.com/api/webhooks/1273867129837588490/XWNQQ3wUaaZAJBE5qWJF7ariAj0reML1F3G0Mf37bQkfNoc2vGsUOJx56QKckTAnFmPJ'
36313065656662613634306135303732353264643466353630393831333765336238633539666238 BOT_USERNAME='ResticBackup'
30623937393835393264616539653530346362663164323134653663613138353336383836346537 MESSAGE_CONTENT=$1
62326530306239616635383734333637326532373230666562336565643163633464613230353064 ICON='https://cdn1.iconfinder.com/data/icons/biometric-3/64/data-transfer-backup-copy-duplication-512.png'
66303433633735616262616235316231616664613730623534636566353964653461393039393537
65616364653638303630323662653231336135393330646536393262383966613466326663336333 # Send message to Discord
36316334626133626665313735626136613838386437326262383963323634393132353263323431 curl -X POST \
63336331343636633631623939346237366365663832323234383262313835373561633933306633 -H 'Content-Type: application/json' \
38646663333035333166653237396139383061373538353462646463666463333466623066326362 -d '{"content":"'"${MESSAGE_CONTENT}"'","username":"'"${BOT_USERNAME}"'","avatar_url":"'"${ICON}"'"}' \
62393363613131633564353365326238303238333963383633313131386661306638383931306436 ${WEBHOOK_URL}
31396564653533616231383332393566376237353634616564396164663435313464373938313266 misamisa_hostkey: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOsDIrV6QIMtpJFNpZEgHnkYgFC6OXMJQFc1JqrnpCzY fake@gmail.co
38623638353438356563343038333835363130653139313066613434383637313938663961356637 ansible_priv_key: |
36366464333666356632383039353961656632366363336364333533656135373464313334643262 -----BEGIN OPENSSH PRIVATE KEY-----
38343431386232303965663562653063666631653765316538383631633963353335303234616332 b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
35663034663230343030636638636436653534346638353730323032383363363164343530333937 QyNTUxOQAAACCIzAw4Yp6ZwjxVDBEWv7S2Mps0SPKCaAL12ZwR/cKQOAAAAJg8/0/NPP9P
32303632363435306262396364633230653062376330633630376331336336633532616530396661 zQAAAAtzc2gtZWQyNTUxOQAAACCIzAw4Yp6ZwjxVDBEWv7S2Mps0SPKCaAL12ZwR/cKQOA
65643538393230393834393839653432636339306462333566313564383231313736303661656662 AAAEDYj9XRxP9WZ74LEPJcbH0Qe2uZ2ojmLiy7z7QlRUg5qIjMDDhinpnCPFUMERa/tLYy
61316362373733383939663236343136663365383239316564323963363532616139303734333566 mzRI8oJoAvXZnBH9wpA4AAAADmZha2VAZ21haWwuY29tAQIDBAUGBw==
66333139343131336533323461363366353965393731613935363466383463383331636361343230 -----END OPENSSH PRIVATE KEY-----
62373335323738653233303062336134363234303938313063333135616335643030346338643634 netbird_setup_key: 397E00DB-A514-441C-B314-B7103A3376FA
66373533623034386461393037313739626135633738653039386263396439666635663333613863 restic_password_value: mLDecjbubXG5Nw1PdSeGbW45f
37333437663837623032343261323435626232346262363631353232643462326561616138343133 aws_access_key_id: NLAjV5dJ802YKg1Z6rXi
36343437643162336237393365363364366164363563343733643265346633663761313030363536 aws_secret_access_key: L6uxy!d%rqhmiFL6uxy!d%rqhmiF
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

135
restore-backups.yml Normal file
View File

@@ -0,0 +1,135 @@
---
- name: Centralized Restic Fleet Restore (Latest Snapshot)
hosts: all
become: true
serial: 1 # Restores are riskier than backups; do one host at a time by default
# Same source/location mapping as run-backups.yaml, kept in sync intentionally.
vars:
# Set to false (default) to require an explicit opt-in before anything destructive happens.
# Run with: ansible-playbook restore-backups.yaml -e "confirm_restore=true"
confirm_restore: false
# Defaults to "latest" per host+tag. Override with -e "restore_snapshot_id=abcd1234"
# to restore a specific snapshot instead.
restore_snapshot_id: "latest"
backup_source_label: >-
{%- if 'app_data' in group_names -%}
apps_data
{%- elif 'app_docker' in group_names -%}
apps_docker
{%- elif 'home_grail' in group_names -%}
home_grail
{%- endif -%}
backup_location: >-
{%- if 'app_data' in group_names -%}
/apps/data/
{%- elif 'app_docker' in group_names -%}
/apps/docker/
{%- elif 'home_grail' in group_names -%}
/home/grail/
{%- endif -%}
restic_env: &restic_env
RESTIC_REPOSITORY: "s3:http://misamisa.duckdns.org:9000/resticbackup"
RESTIC_PASSWORD: "{{ vault_restic_password }}"
AWS_ACCESS_KEY_ID: "{{ vault_aws_access_key_id }}"
AWS_SECRET_ACCESS_KEY: "{{ vault_aws_secret_access_key }}"
tasks:
- name: Refuse to proceed without explicit confirmation
ansible.builtin.assert:
that:
- confirm_restore | bool
fail_msg: >-
This playbook will overwrite {{ backup_location }} on {{ inventory_hostname }}
with data from a restic snapshot. Re-run with -e "confirm_restore=true" to proceed,
optionally with -e "restore_snapshot_id=<id>" to pick a snapshot other than latest.
success_msg: "Confirmed. Proceeding with restore on {{ inventory_hostname }}."
- name: Fail fast if backup_location/backup_source_label could not be resolved
ansible.builtin.assert:
that:
- backup_location | trim | length > 0
- backup_source_label | trim | length > 0
fail_msg: >-
Host {{ inventory_hostname }} did not match any known inventory group
(app_data, app_docker, home_grail). Check group membership.
- name: List available snapshots for this host/tag (for the log)
community.docker.docker_container:
name: restic_snapshots_list
image: restic/restic:latest
state: started
detach: false
cleanup: true
output_logs: true
command: >-
snapshots
--host "{{ inventory_hostname }}"
--tag "{{ backup_source_label }}"
env: *restic_env
register: restic_snapshots_result
- name: Show available snapshots
ansible.builtin.debug:
var: restic_snapshots_result.container.Output
- name: Restore Sequence with Safety Catch
block:
- name: Gracefully stop the application via Systemd
ansible.builtin.systemd:
name: app
state: stopped
- name: Ensure restore target exists with correct ownership before mounting
ansible.builtin.file:
path: "{{ backup_location }}"
state: directory
owner: docker
group: docker
mode: "0755"
- name: Check for and remove stale locks
community.docker.docker_container:
name: restic_unlock
image: restic/restic:latest
state: started
detach: false
cleanup: true
command: "unlock"
env: *restic_env
register: restic_unlock_result
failed_when: restic_unlock_result.status != 0
- name: Restore latest snapshot into place
community.docker.docker_container:
name: restic_restore
image: restic/restic:latest
state: started
detach: false
cleanup: true
timeout: 600
output_logs: true
command: >-
restore {{ restore_snapshot_id }}
--host "{{ inventory_hostname }}"
--tag "{{ backup_source_label }}"
--target /
volumes:
# NOTE: rw (no :ro) here — this is the whole point of a restore.
- "{{ backup_location }}:/backup_target/{{ backup_source_label }}"
env: *restic_env
register: restic_restore_result
failed_when: restic_restore_result.status != 0
- name: Show restore output
ansible.builtin.debug:
var: restic_restore_result.container.Output
always:
- name: Ensure the application is started back up
ansible.builtin.systemd:
name: app
state: started

129
run-backups.yaml Normal file
View File

@@ -0,0 +1,129 @@
---
- name: Centralized Restic Fleet Backup with Systemd Hooks
hosts: all
become: true
serial: 5
vars:
# Map of group -> {label, path}. A host can belong to more than one of
# these groups (e.g. semaphore, which spans apps_data and apps_docker);
# backup_targets below collects ALL matching entries for this host, so
# everything gets backed up under a single stop/start cycle.
group_paths:
app_data:
label: apps_data
path: /apps/data/
app_docker:
label: apps_docker
path: /apps/docker/
home_grail:
label: home_grail
path: /home/grail/
backup_targets: "{{ group_paths | dict2items | selectattr('key', 'in', group_names) | map(attribute='value') | list }}"
restic_env: &restic_env
RESTIC_REPOSITORY: "s3:http://misamisa.duckdns.org:9000/resticbackup"
RESTIC_PASSWORD: "{{ vault_restic_password }}"
AWS_ACCESS_KEY_ID: "{{ vault_aws_access_key_id }}"
AWS_SECRET_ACCESS_KEY: "{{ vault_aws_secret_access_key }}"
tasks:
- name: Fail fast if this host matches no known group
ansible.builtin.assert:
that:
- backup_targets | length > 0
fail_msg: >-
Host {{ inventory_hostname }} is not in any group listed in group_paths
(app_data, app_docker, home_grail). Check group membership.
- name: Execute Backup Sequence with Safety Catch
block:
- name: Gracefully stop the application via Systemd
ansible.builtin.systemd:
name: app
state: stopped
- name: Check for and remove stale locks
community.docker.docker_container:
name: restic_unlock
image: restic/restic:latest
state: started
detach: false
cleanup: true
command: "unlock"
env: *restic_env
register: restic_unlock_result
failed_when: restic_unlock_result.status != 0
- name: Init restic repo (per target)
community.docker.docker_container:
name: "restic_init_{{ item.label }}"
image: restic/restic:latest
state: started
detach: false
cleanup: true
command: "init"
volumes:
- "{{ item.path }}:/backup_target/{{ item.label }}:ro"
env: *restic_env
register: restic_init_result
failed_when:
- restic_init_result.status != 0
- "'already initialized' not in restic_init_result.container.Output"
loop: "{{ backup_targets }}"
loop_control:
label: "{{ item.label }}"
- name: Run restic backup (per target)
community.docker.docker_container:
name: "restic_backup_{{ item.label }}"
image: restic/restic:latest
state: started
detach: false
cleanup: true
timeout: 600
output_logs: true
command: >-
backup /backup_target/{{ item.label }}
--host "{{ inventory_hostname }}"
--tag "{{ item.label }}"
volumes:
- "{{ item.path }}:/backup_target/{{ item.label }}:ro"
env: *restic_env
register: restic_backup_result
loop: "{{ backup_targets }}"
loop_control:
label: "{{ item.label }}"
- name: Show backup output
ansible.builtin.debug:
msg: "{{ item.container.Output }}"
loop: "{{ restic_backup_result.results }}"
loop_control:
label: "{{ item.item.label }}"
- name: Prune old snapshots (per target)
community.docker.docker_container:
name: "restic_prune_{{ item.label }}"
image: restic/restic:latest
state: started
detach: false
cleanup: true
command: >-
forget
--host "{{ inventory_hostname }}"
--tag "{{ item.label }}"
--keep-daily 7 --keep-weekly 4 --keep-monthly 12 --prune
volumes:
- "{{ item.path }}:/backup_target/{{ item.label }}:ro"
env: *restic_env
register: restic_prune_result
loop: "{{ backup_targets }}"
loop_control:
label: "{{ item.label }}"
always:
- name: Ensure the application is started back up
ansible.builtin.systemd:
name: app
state: started