I have a server and a desktop both using btrfs for most of my file systems. The server contains media; documents, pictures, music, etc., for use via DLNA. The server has 2 pairs of drives in RAID1 (duplicate) configuration using btrfs. RAID1 is an excellent to way to protect you from drive failure event. If one drive fails, you replace it and rebuild the RAID1 array.
However, most people will tell you RAID1 isn't a backup - and it's not. For example, if I log into the server and accidentally delete my family photos folder from 2009, it's gone - on both drives. So backups are needed to protect from dumb mistakes. Also, random file system corruption or some other catastrophic event could wipe the entire file system.
So I needed a backup procedure to go along with the RAID1 configuration. It is better to have your backup on a different system when possible, so I decided backing up to my desktop was in order, but how to do this?
The btrfs backup procedure uses the "send" and "receive" commands to copy an entire subvolume from one btrfs filesystem to another. I have used this many times on a single machine, but never tried to do it between two machines. Since I already use ssh to access the server, it seemed a natural choice to use for this process. There are other methods to copy files from one computer to another, but most (if not all) if them use a network file system of one type or another which means I can't use btrfs. I even tried mounting the target drive using "sshfs" which works, but it's not btrfs, so send|receive was not usable. My desire was to use a simple bash script and a cronjob to send backups of the important data like family photos to my desktop computer in an automated fashion - totally unattended. This means passwords can't be required, since I won't be there to enter them. Also, btrfs commands require root (or sudo) access. Even if it could be done with sudo (it can't over ssh), I don't want my password stored in plain text. Obviously, removing all security just to make backups is a horrible idea, so I needed something better: Root access via SSH using a secure key.
The environment:
The tasks:
This thread borrowed heavily from here and lightly from other locations on the internet.
[#]btrfs[/#] [#]backup[/#] [#]ssh[/#]
However, most people will tell you RAID1 isn't a backup - and it's not. For example, if I log into the server and accidentally delete my family photos folder from 2009, it's gone - on both drives. So backups are needed to protect from dumb mistakes. Also, random file system corruption or some other catastrophic event could wipe the entire file system.
So I needed a backup procedure to go along with the RAID1 configuration. It is better to have your backup on a different system when possible, so I decided backing up to my desktop was in order, but how to do this?
The btrfs backup procedure uses the "send" and "receive" commands to copy an entire subvolume from one btrfs filesystem to another. I have used this many times on a single machine, but never tried to do it between two machines. Since I already use ssh to access the server, it seemed a natural choice to use for this process. There are other methods to copy files from one computer to another, but most (if not all) if them use a network file system of one type or another which means I can't use btrfs. I even tried mounting the target drive using "sshfs" which works, but it's not btrfs, so send|receive was not usable. My desire was to use a simple bash script and a cronjob to send backups of the important data like family photos to my desktop computer in an automated fashion - totally unattended. This means passwords can't be required, since I won't be there to enter them. Also, btrfs commands require root (or sudo) access. Even if it could be done with sudo (it can't over ssh), I don't want my password stored in plain text. Obviously, removing all security just to make backups is a horrible idea, so I needed something better: Root access via SSH using a secure key.
The environment:
A server and a desktop computer on an internal network, behind the firewall, both with openssh-client and -server installed.
The tasks:
- Securely gain root level ssh access from the server to the desktop without requiring a password.
- Verify the use of btrfs send|receive over ssh.
- Automate the backup process.
This thread borrowed heavily from here and lightly from other locations on the internet.
[#]btrfs[/#] [#]backup[/#] [#]ssh[/#]
Comment