Difference between revisions of "Backups"

From Briki
Jump to: navigation, search
(Listing previous snapshots)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
== Update restic ==
 +
  restic self-update
 +
 
== Listing previous snapshots ==
 
== Listing previous snapshots ==
 
   sudo -i
 
   sudo -i
 
   . /etc/restic-init
 
   . /etc/restic-init
 
   restic snapshots
 
   restic snapshots
 +
 +
== Listing contents of the latest snapshot ==
 +
  sudo -i
 +
  . /etc/restic-init
 +
  restic ls -l latest
 +
 +
== Deleting old snapshots ==
 +
Substitute `2021-12` with the month (or months) for which you want to keep a full history. Note: `2019-03-26` is the first-ever backup in this instance, so we want to keep that too.
 +
  for snap in `restic snapshots -c | grep maine | sed -e 's!.* !!' | grep -v -- '-01$' | grep -v '2019-03-26' | grep -v '2021-12'`
 +
  do
 +
    restic forget --path /var/backup/snapshot/latest --tag $snap --keep-last=-1
 +
  done
 +
 +
== Pruning old history ==
 +
Note: This will also trim the size of the /root/.cache/restic directory
 +
  sudo -i
 +
  . /etc/restic-init
 +
  restic prune

Latest revision as of 07:12, 20 May 2022

Update restic

 restic self-update

Listing previous snapshots

 sudo -i
 . /etc/restic-init
 restic snapshots

Listing contents of the latest snapshot

 sudo -i
 . /etc/restic-init
 restic ls -l latest

Deleting old snapshots

Substitute `2021-12` with the month (or months) for which you want to keep a full history. Note: `2019-03-26` is the first-ever backup in this instance, so we want to keep that too.

 for snap in `restic snapshots -c | grep maine | sed -e 's!.* !!' | grep -v -- '-01$' | grep -v '2019-03-26' | grep -v '2021-12'`
 do
   restic forget --path /var/backup/snapshot/latest --tag $snap --keep-last=-1
 done

Pruning old history

Note: This will also trim the size of the /root/.cache/restic directory

 sudo -i
 . /etc/restic-init
 restic prune