vendredi 20 septembre 2019

Backup disks on samba server with fsarchiver

fsarchiver : http://www.fsarchiver.org/

Install samba client
sorry, use google...

Mount samba folder

sudo mkdir /media/nas
nano ~/.smbcredentials

Add this: 
user=nasuser
password=naspass
 

Save and:   
chmod 0600 ~/.smbcredentials
 

sudo nano /etc/fstab


Add this:
//192.168.1.230/commun  /media/nas cifs  credentials=/home/pi/.smbcredentials,x-systemd.automount,defaults 0 0

Save and:

Install fsarchiver

sudo apt install fsarchiver

Backup your disks

Display your disks:

sudo fdisk -l
.
.
.

Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk0p1       8192   93813   85622 41,8M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      94208 5678280 5584073  2,7G 83 Linux



Before backup, a good idea is to use SCREEN:

Install screen
sudo apt install screen 

Create a vitual screen:

sudo screen -S backup 

Archive the boot particion:
sudo fsarchiver -A savefs /media/nas/boot_`date +%y-%m-%d`.fsa /dev/mmcblk0p1

    Statistics for filesystem 0
    * files successfully processed:....regfiles=216, directories=3, symlinks=0, hardlinks=0, specials=0
    * files with errors:...............regfiles=0, directories=0, symlinks=0, hardlinks=0, specials=0


Archive the system partition:
sudo fsarchiver -A savefs /media/nas/root_`date +%y-%m-%d`.fsa /dev/mmcblk0p2

... take long time ZZZ zzzz ...

Ctrl a + d to quit the virtual screen

To check backup progress, enter in screen :

sudo screen -x backup
Ctrl a + d


Etc... (You can close ssh session, and re enter in screen)

And a very long time after:

15193+1 enregistrements lus
15193+1 enregistrements écrits
15931539456 bytes (16 GB, 15 GiB) copied, 3750,82 s, 4,2 MB/s
root@cabass:/home/pi# sudo fsarchiver -A savefs /media/nas/cabass-system.fsa /dev/mmcblk0p2
Statistics for filesystem 0
* files successfully processed:....regfiles=66035, directories=7967, symlinks=13449, hardlinks=209, specials=222
* files with errors:...............regfiles=0, directories=0, symlinks=0, hardlinks=0, specials=0


On destination samba server you have two new files:
ie.:
boot_19-09-29.fsa
root_19-09-29.fsa


Restoring:

fsarchiver restfs /media/nas/cabass-boot.fsa id=0,dest=/dev/mmcblk0p1

and:


fsarchiver restfs /media/nas/cabass-system.fsa id=0,dest=/dev/mmcblk0p2


Aucun commentaire:

Enregistrer un commentaire