Backup/Restic: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
Created page with "==Backup » Restic== {|class='wikitable mw-collapsible' style='width:100%' !scope='col' style='text-align:left'| Backup » [https://restic.net/ Restic] |- |valign='top'| {|class='wikitable mw-collapsible mw-collapsed' style='width:100%;margin:3px 0 3px 0' !scope='col' style='text-align:left'| Restic » Install |- |valign='top'| <syntaxhighlight style='margin:3px 0 3px 0' lang='bash'> cat <<'EXE' | sudo bash apt-get update apt-get install -y restic restic version apt-get..."
 
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Backup » Restic==
==Backup » Restic==
{|class='wikitable mw-collapsible' style='width:100%'
{|class='wikitable mw-collapsible'
!scope='col' style='text-align:left'|
!scope='col' style='text-align:left'|
Backup » [https://restic.net/ Restic]
Backup » [https://restic.net/ Restic]
|-
|-
|valign='top'|
|valign='top'|
{|class='wikitable mw-collapsible mw-collapsed' style='width:100%;margin:3px 0 3px 0'
{|class='wikitable mw-collapsible mw-collapsed'
!scope='col' style='text-align:left'|
!scope='col' style='text-align:left'|
Restic » Install
Restic » Install
|-
|-
|valign='top'|
|valign='top'|
<syntaxhighlight style='margin:3px 0 3px 0' lang='bash'>
<syntaxhighlight lang='bash'>
cat <<'EXE' | sudo bash
cat <<'EXE' | sudo bash
apt-get update
apt-get update
Line 21: Line 21:
|-
|-
|valign='top'|
|valign='top'|
<syntaxhighlight style='margin:3px 0 3px 0' lang='bash'>
<syntaxhighlight lang='bash'>
cat <<'EXE' | sudo bash
cat <<'EXE' | sudo bash
echo
RESTIC_ARCH="$(echo "$(uname -s)_$(dpkg --print-architecture)"|tr '[:upper:]' '[:lower:]')"
RESTIC_HOME="/opt/cli/$(echo "restic-$(uname -s)-$(dpkg --print-architecture)"|tr '[:upper:]' '[:lower:]')"
RESTIC_VERSION=$(curl -s https://api.github.com/repos/restic/restic/releases/latest | grep -Po '"tag_name": "v\K[^"]*')
curl -fsSLo restic.bz2  https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_${RESTIC_ARCH}.bz2
bzip2 -fd  restic.bz2  && install restic /usr/local/bin
rm  -rf    restic.bz2  restic
EXE
EXE


Line 30: Line 35:
</syntaxhighlight>
</syntaxhighlight>
|}
|}
{|class='wikitable mw-collapsible mw-collapsed' style='width:100%;margin:6px 0 3px 0'
{|class='wikitable mw-collapsible mw-collapsed'
!scope='col' style='text-align:left|
!scope='col' style='text-align:left'|
Restic » Config
Restic » Config
|-
|-
|valign='top'|
|valign='top'|
<syntaxhighlight style='margin:3px 0 3px 0' lang='bash'>
<syntaxhighlight lang='bash'>
cat <<'EXE' | sudo bash
export RESTIC_REPOSITORY="s3:https://s3.minio.host.k8s.ops/shahed-bkp/academia"
echo
echo -n 'Password: ';read -s RESTIC_PASSWORD;      export RESTIC_PASSWORD;echo
EXE
# Password: #evd0wxuV$jNJqWL
 
echo -n 'AccessKey: ';read -s AWS_ACCESS_KEY_ID;    export AWS_ACCESS_KEY_ID;echo
echo -n 'SecretKey: ';read -s AWS_SECRET_ACCESS_KEY;export AWS_SECRET_ACCESS_KEY;echo
</syntaxhighlight>
</syntaxhighlight>
|}
|}
{|class='wikitable mw-collapsible' style='width:100%;margin:6px 0 3px 0'
{|class='wikitable mw-collapsible'
!scope='col' style='text-align:left|
!scope='col' style='text-align:left'|
Restic » Backup
Restic » Backup
|-
|-
|valign='top'|
|valign='top'|
<syntaxhighlight style='margin:3px 0 3px 0' lang='bash'>
<syntaxhighlight lang='bash'>
cat <<'EXE' | sudo bash
restic backup \
echo
--repo ${HOME}/backups/academia.chorke.org-prod-apps/ \
EXE
${HOME}/sites/academia.chorke.org/releases \
${HOME}/sites/academia.chorke.org/storage \
${HOME}/sites/academia.chorke.org/shared \
--exclude=${HOME}/sites/academia.chorke.org/shared/storage/ \
--tag app=academia.chorke.org \
--tag server=chorke-academia
 
:'
repository 5f79eedd opened (version 2, compression level auto)
using parent snapshot 71294ebe
[0:00] 100.00%  1 / 1 index files loaded
 
Files:          0 new, 27526 changed,    0 unmodified
Dirs:            0 new,  6834 changed,    0 unmodified
Added to the repository: 24.904 MiB (4.578 MiB stored)
 
processed 27526 files, 599.073 MiB in 0:24
snapshot be02db43 saved
'
</syntaxhighlight>
|}
{|class='wikitable mw-collapsible mw-collapsed'
!scope='col' style='text-align:left'|
Restic » Forget
|-
|valign='top'|
<syntaxhighlight lang='bash'>
restic forget --compact \
--repo ${HOME}/backups/academia.chorke.org-prod-apps/ \
--keep-hourly 36 --keep-daily 45 --keep-weekly 15 --keep-monthly 15 --keep-yearly 8 --prune
 
:'
Applying Policy: keep 36 hourly, 45 daily, 15 weekly, 15 monthly, 8 yearly snapshots
keep 2 snapshots:
ID        Time                Host            Tags
-----------------------------------------------------------------------
71294ebe  2025-12-02 15:21:18  chorke-academia
be02db43  2025-12-03 07:59:16  chorke-academia  app=academia.chorke.org
                                                server=chorke-academia
-----------------------------------------------------------------------
2 snapshots
'
</syntaxhighlight>
|}
{|class='wikitable mw-collapsible mw-collapsed'
!scope='col' style='text-align:left'|
Restic » Snapshot
|-
|valign='top'|
<syntaxhighlight lang='bash'>
restic snapshots --compact \
--repo ${HOME}/backups/academia.chorke.org-prod-apps/
 
:'
repository 5f79eedd opened (version 2, compression level auto)
ID        Time                Host            Tags
-----------------------------------------------------------------------
71294ebe  2025-12-02 15:21:18  chorke-academia
be02db43  2025-12-03 07:59:16  chorke-academia  app=academia.chorke.org
                                                server=chorke-academia
-----------------------------------------------------------------------
2 snapshots
'
</syntaxhighlight>
</syntaxhighlight>
|}
|}
Line 55: Line 125:


==References==
==References==
{|class='wikitable mw-collapsible' style='width:100%'
{|class='wikitable mw-collapsible'
!scope='col' style='text-align:left' colspan='3'|
!scope='col' style='text-align:left' colspan='3'|
References
References

Latest revision as of 16:43, 18 January 2026

Backup » Restic

Backup » Restic

Restic » Install

cat <<'EXE' | sudo bash
apt-get update
apt-get install -y restic
restic version
apt-get clean
EXE
cat <<'EXE' | sudo bash
RESTIC_ARCH="$(echo "$(uname -s)_$(dpkg --print-architecture)"|tr '[:upper:]' '[:lower:]')"
RESTIC_HOME="/opt/cli/$(echo "restic-$(uname -s)-$(dpkg --print-architecture)"|tr '[:upper:]' '[:lower:]')"
RESTIC_VERSION=$(curl -s https://api.github.com/repos/restic/restic/releases/latest | grep -Po '"tag_name": "v\K[^"]*')
curl -fsSLo restic.bz2   https://github.com/restic/restic/releases/download/v${RESTIC_VERSION}/restic_${RESTIC_VERSION}_${RESTIC_ARCH}.bz2
bzip2 -fd   restic.bz2   && install restic /usr/local/bin
rm   -rf    restic.bz2   restic
EXE

which restic
restic version

Restic » Config

export RESTIC_REPOSITORY="s3:https://s3.minio.host.k8s.ops/shahed-bkp/academia"
echo -n 'Password: ';read -s RESTIC_PASSWORD;       export RESTIC_PASSWORD;echo
# Password: #evd0wxuV$jNJqWL

echo -n 'AccessKey: ';read -s AWS_ACCESS_KEY_ID;    export AWS_ACCESS_KEY_ID;echo
echo -n 'SecretKey: ';read -s AWS_SECRET_ACCESS_KEY;export AWS_SECRET_ACCESS_KEY;echo

Restic » Backup

restic backup \
 --repo ${HOME}/backups/academia.chorke.org-prod-apps/ \
 ${HOME}/sites/academia.chorke.org/releases \
 ${HOME}/sites/academia.chorke.org/storage \
 ${HOME}/sites/academia.chorke.org/shared \
 --exclude=${HOME}/sites/academia.chorke.org/shared/storage/ \
 --tag app=academia.chorke.org \
 --tag server=chorke-academia

:'
repository 5f79eedd opened (version 2, compression level auto)
using parent snapshot 71294ebe
[0:00] 100.00%  1 / 1 index files loaded

Files:           0 new, 27526 changed,     0 unmodified
Dirs:            0 new,  6834 changed,     0 unmodified
Added to the repository: 24.904 MiB (4.578 MiB stored)

processed 27526 files, 599.073 MiB in 0:24
snapshot be02db43 saved
'

Restic » Forget

restic forget --compact \
 --repo ${HOME}/backups/academia.chorke.org-prod-apps/ \
 --keep-hourly 36 --keep-daily 45 --keep-weekly 15 --keep-monthly 15 --keep-yearly 8 --prune

:'
Applying Policy: keep 36 hourly, 45 daily, 15 weekly, 15 monthly, 8 yearly snapshots
keep 2 snapshots:
ID        Time                 Host             Tags
-----------------------------------------------------------------------
71294ebe  2025-12-02 15:21:18  chorke-academia
be02db43  2025-12-03 07:59:16  chorke-academia  app=academia.chorke.org
                                                server=chorke-academia
-----------------------------------------------------------------------
2 snapshots
'

Restic » Snapshot

restic snapshots --compact \
 --repo ${HOME}/backups/academia.chorke.org-prod-apps/

:'
repository 5f79eedd opened (version 2, compression level auto)
ID        Time                 Host             Tags
-----------------------------------------------------------------------
71294ebe  2025-12-02 15:21:18  chorke-academia
be02db43  2025-12-03 07:59:16  chorke-academia  app=academia.chorke.org
                                                server=chorke-academia
-----------------------------------------------------------------------
2 snapshots
'

References

References