Backup Sismologie rsync ZFS snapshosts Linux (like) laptop

1 : make an ssh key without passwd (for backup)

Use this command for that :

ssh-keygen -t rsa -f .ssh/id_rsa_backup-bigfish

Exemple :

nomad@magister:~$ 
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): don't write anything here just push enter
Enter same passphrase again: don't write anything here just push enter
Your identification has been saved in .ssh/id_rsa_backup-bigfish.
Your public key has been saved in .ssh/id_rsa_backup-bigfish.pub.
The key fingerprint is:
SHA256:y2XxEFXUnhfEjma6FpMIWdkpK0S/ghndS+qrmpR9hyo nomad@magister
The key's randomart image is:
+---[RSA 2048]----+
|      ..  +.oo=o |
|      ..o+ +   o.|
|     ...o+=   o.o|
|      ++o.o+ + oo|
|     o oSo+ *   .|
|    o ..o= =     |
|   o . +o.  +    |
|  .E. o o  o     |
|   ooo..  .      |
+----[SHA256]-----+
nomad@magister:~$ 

2 : send a mail to your sysadmin

Send a mail to your sysadmin to ask for a backup volume.
With your ethernet IP adress and Mac adress related.

Use this command to find it :

ifconfig

Put also inside the mail your ssh-key id_rsa_backup-bigfish.pub created just before.

To show it inside a terminal you can type this :

cat ~/.ssh/id_rsa_backup-bigfish.pub

Copy the result inside ce mail.

You shoud obtain something like that :

ssh-rsa AAAAB3NzaC [ ... don't copy this one ... ] QrSvwSJQkD user@laptop

Please give also the file name : like : id_rsa_backup-bigfish.pub

Then wait that your sysadmin answer or go to see him.

3 : backup script

install it
mkdir ~/bin
cd ~/bin
wget https://github.com/nomad-fr/rsync-snapshot-notification/archive/master.zip
unzip master.zip
cd rsync-snapshot-notification-master
configure backup script

Launch it like this :

./backup-rsync-snapshot.sh 

It shoud tell you to fill config file : backup-rsync-snapshot.conf like this :
/!\ You have to ajust them.
At least the 3 first one : SRC, CLEF, VOL

SRC=~                             # source dir to backup here ~ means users home
CLEF=~/.ssh/id_rsa_backup-bigfish # backup ssh key to use (the one you send to your admin)
VOL=volume-name-given-by-admin    # final destination volume name (given by admin in mail)

EXCLUDE_FILE=""                   # file for exluded files
BACKUP_FOLDER=""                  # autofs mount point : can be unset 
                                  # ex : /media/gobt/Backup-sismo-capsule/snapshot

HOST=bigfish                      # host use for backup : here in IPGP seismologie it's bigfish
ZFS_VOL_DEST=dam/capsule/zfs      # zfs vol name use for backup : actual path for capsule backup

EXCLUDE_FILE : Specifies a FILE that contains exclude patterns (one per line). Blank lines in the file and lines starting with ; or # are ignored.

You can put your EXCLUDE_FILE near you conf file, then you have to put something like this inside : EXCLUDE_FILE=“./exclude”

ex of an “EXCLUDE_FILE” file :

.thumbnails
.googlearth
.cache
.gnome2/keyrings/trash
.thunderbird/*/ImapMail
Nextcloud
Cloud-CNRS
VersionControl

Here you have to put path from yout source dir. In this exemple the folder Nextcloud is in my home so it real path ~/Nextcloud . In this case you just have tyo put Nextcloud in you exclude file.

Configuration files backup-rsync-snapshot.conf have to be in the same folder as backup-rsync-snapshot.sh

4 : launch it

cd ~/bin/rsync-snapshot-notification-master
  • just run :
./backup-rsync-snapshot.sh 
  • you should see something like :
sending incremental file list
[...]
[... all your files ...]
[...]
sent 579,379 bytes  received 16,725 bytes  79,480.53 bytes/sec
total size is 2,912,441,874  speedup is 4,885.79

[./backup-rsync-snapshot.sh] : rsync done now snapshot it
Doing zfs hourly snapshots:
     taking snapshot: dam/capsule/zfs/emmett@hourly-2017-10-11-16
Doing zfs daily snapshots:
     taking snapshot: dam/capsule/zfs/emmett@daily-2017-10-11
Doing zfs weekly snapshots:
     taking snapshot: dam/capsule/zfs/emmett@weekly-2017-41
Doing zfs monthly snapshots:
     taking snapshot: dam/capsule/zfs/emmett@monthly-2017-10
snapshost Done :  backup finish

If the end don’t like this,

snapshost Done :  backup finish

then you have rsync trouble, and maybe you need an exclude file for some rep.

5 : schedule it

you can use cron or my nootification app see bellow.

cron

Edit your crontab or anything you want for that.

see : https://help.ubuntu.com/community/CronHowto#Crontab_Lines

doggy style notification with xfce and autostart
  • write a script like this one : launch-backup-with-notification.sh
#!/usr/bin/env bash

cd ~/bin/rsync-snapshot-notification-master/
./backup-notification.py ./backup-rsync-snapshot.sh 
  • Autostart it by addind it to Auto Start App

in xfce Parametes : Session and startup : Auto Start App :
add : command : /home/moncompte/bin/launch-backup-with-notification.sh

6 : accé aux sauvegardes (historique)

Install and configure autofs
sudo apt install autofs nfs-common
  • add this to /etc/auto.master :
/media/backup-Sismo                         /etc/auto.backup --ghost,--timeout=60
  • add this to /etc/auto.backup :

You have to change volume-name-given-by-admin to your VOL name : see your config.

volume-name-given-by-admin	 -fstype=nfs,ro,intr    bigfish:/dam/capsule/zfs/volume-name-given-by-admin/snapshot
sudo service autofs restart
  • You will see then (when it’s done) your last backup inside /media/Backup-sismo-capsule