Sometimes our system crash down and it could lead to a total/partial loss of our files, which is definitely not a good moment for us. There are several reasons that cause the crash, and we can mainly divide the reasons into three categories,

  • software
  • hardware
  • other

Most of the time, if the crash is cause by software related reasons and only has impact on software level, we would be fine as long as we can restart our machine and try to recover our files. For example, there are plenty of methods to recover a file after there is a

1rm -rf / 

been operated unexpected, even if you are using a SSD.

However, if there are faults on SSD, which means the crash maybe cause by a part of the SSD at the hardware level, then we are f**ked. It is impossible to predict when will my SSD goes down, but we can always do something to guard our files and work!

We can backup our file system with a cloud storage provider or a big volume storage in our home. Personally I do not recommend cloud storage service as they are either

  • expensive
  • security/privacy issues
  • data transfer

And I would always wondering after I upload my data onto the cloud, my data would never be mine! For Windows users, oneDrive is the best choice for backup as it is provided by Microsoft(yes, that is the most important reason). For Linux users, iDrive would be a great choice. And if you want to set up a cloud service on your VPS/physical server, nextcloud could be the start point.

I could have setup a nextcloud service in my home’s local network, but I didn’t - I do not need the fancy APIs or interface. All I want is copy and store. As I have got an 8TB hard drive, I just plugged it with my Linux desktop and then mount it to a directory. Then I had a lot of choices for doing backup, or, disk cloning,

  • fsarchiver
  • Clonezilla
  • Redo Backup
  • dd

I chose fsarchiver as my backup tool as it is straightforward,

1sudo fsarchiver savefs -Z22 -A /diskB/back.fsa /dev/mapper/rhel-home /dev/mapper/rhel/root

in this command, parameter “Z22” means compress level of 22, which is the biggest one provided by fsarchiver thus would save the space for my backup disk. “/diskB/back.fsa” contains the mounted point of my backup disk and “back.fsa” is the name of the compressed backup file. I chose to make a copy of both my home and root which consist of all my essential data. In case of a failure of my system disk(which is an SSD), I could pull the data from my backup disk and extract to get my home and root, then recover my files. I would recommend do a backup every day or once after some big improvement has been done.

If you want to do the backup faster by fully exploiting the your processors, then

1sudo fsarchiver savefs -Z22 -A /diskB/back.fsa /dev/mapper/rhel-home /dev/mapper/rhel/root -j8

Which means I would like fsarchiver making a backup with 8 threads. But remember, I/O would always be the bottleneck and drag the overall performance.

To restore file, it is very easy as I mentioned above,

1fsarchiver restfs /diskB/back.fsaa id=0,dest=/dev/sda1, mkfs=reiserfs

where dest=/dev/sdaq is the destination partition and mkfs=reiserfs specifies covnerting the backup files to ReiserFS(file system). More information about fsarchiver can be seen at their quickstart guide.

If we want to expose our 8TB drive to other clients in the local network, what should I do? This can be done quickly with a popular long history technique - samba. And if we want to share files between Windows and Linux, how to configure it? Use cifs.

Firstly, install cifs on my Linux machine,

1sudo yum install cifs-utils

and make a directory as the mounting point,

1mkdir windows-share

then, we are donw

1sudo mount -t cifs -o username=me //192.168.1.2/windows-share /home/windows-share

Sometimes the GUI would auto-mount the disk to a weird location and you can not share that directory with samba even you su to the root user. At that time, we need to manually unmount the partition and mount it later with the command above. You can setup a password for your self-hosted file sharing to make sure it is safer(I did not do so becuase I think forgetting password tends to happen frequently thus would be more tricky for me)