Skip to main content

Restic : Ligne de commandes

Bashrc & Alias

Sur votre utilisateur courant (différent de root), éditer votre fichier bashrc vim /home/user/.bashrc

alias restic='restic --insecure-tls'
export RESTIC_PASSWORD="${USER_MDP}"
export RESTIC_REPOSITORY="rest:https://${USER_PROJECT}:${USER_MDP}@${SRV_RESTIC}:${PORT_EXPOSED}/"

Cela permet ensuite d'utiliser le binaire vers votre dépôt de sauvegarde sans à divulguer toutes les informations :

zayad@vmi2007645:~$ restic stats
repository 6d0ed1e0 opened (repository version 2) successfully, password is correct
scanning...
Stats in restore-size mode:
Snapshots processed:   2
   Total File Count:   281
         Total Size:   24.191 KiB

Backing Up

restic -r rest:https://${USER_PROJECT}:${USER_MDP}@${SRV_RESTIC}:${PORT_EXPOSED} --insecure-tls backup ~/directory-to-backup --pack-size=60

Cleanup

With every backup, Restic is creating a new snapshot with contents of a directory at the moment. To remove old and unused snapshots we need to execute the forget command:

restic -r rest:https://${USER_PROJECT}:${USER_MDP}@${SRV_RESTIC}:${PORT_EXPOSED} --insecure-tls forget --keep-last 2 --prune

Check

If you want to verify the consistency of your backup, run the check command:

restic -r rest:https://${USER_PROJECT}:${USER_MDP}@${SRV_RESTIC}:${PORT_EXPOSED} --insecure-tls check

Restore

To restore the latest snapshot of your backup:

restic -r rest:https://${USER_PROJECT}:${USER_MDP}@${SRV_RESTIC}:${PORT_EXPOSED} --insecure-tls restore latest --target ~/restore