User:Nomaster/Backup: Difference between revisions

From Chaosdorf Wiki
(Undo revision 7234 by 222.76.93.71 (talk) spam)
m (Reverted edits by 46.161.9.56 (talk) to last revision by Nomaster)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This article is a couple of years old and I have already moved all of my precious data into the cloud. Because the flying spaghetti monster will save us all. Not.
...but I am still convinced this may be helpful to you.
<blockquote>
<blockquote>
Jesus saves. Buddha does incremental backups.
Jesus saves. Buddha does incremental backups.
Line 33: Line 37:
   cryptsetup luksOpen /dev/sdb backup
   cryptsetup luksOpen /dev/sdb backup


Inside, there is [[Wikipedia:Btrfs|btrfs]] filesystem, I mount using compression.
If not happened yet, format the drive with a [[Wikipedia:Btrfs|btrfs]] filesystem
 
  mkfs.btrfs -L backup /dev/mapper/backup
 
Then, mount it and use compression
 
  mount -o compress=lzo -t btrfs LABEL=backup /media/backup
 
If not happened yet, create a subvolume


   mount -o compress -t btrfs /dev/sdb /mnt/backup
   btrfs subvolume create /media/backup/nomaster


For may backups, I use rsync (with delete) to copy my files to an external hard drive. Vanished files will be deleted.
For may backups, I use rsync (with delete) to copy my files to an external hard drive. Vanished files will be deleted.
    
    
   rsync -aPv --delete --exclude downloads --exclude music --exclude .cache /home/nomaster/ /mnt/backup/nomaster/
   rsync -aPv --delete --exclude downloads --exclude music --exclude .cache /home/nomaster/ /media/backup/nomaster/


After each sync, I make a snapshot of this state of my files.
After each sync, I make a snapshot of this state of my files.


   sudo btrfs subvolume snapshot /mnt/backup/nomaster /mnt/backup/nomaster120331
   sudo btrfs subvolume snapshot -r /media/backup/nomaster /media/backup/nomaster-$(date +%F)


Lastly, I unmount the filesystem and close the container.
Lastly, I unmount the filesystem and close the container.


   sudo umount /mnt
   sudo umount /media
   sudo cryptsetup luksClose backup
   sudo cryptsetup luksClose backup



Latest revision as of 04:58, 12 August 2017

This article is a couple of years old and I have already moved all of my precious data into the cloud. Because the flying spaghetti monster will save us all. Not.

...but I am still convinced this may be helpful to you.

Jesus saves. Buddha does incremental backups.

In celebration of World Backup Day, I hereby release my backup strategy.

Features[edit | edit source]

  • daily backup, fully accessible
  • compressed storage
  • block device encryption
  • speed

Requirements[edit | edit source]

  • external harddrive
  • modern linux kernel (use Arch Linux!)
  • current version of btrfs-progs (I have 0.19.20120110-2)
  • a strong password (you may follow this guide or similar)

Daily Routine[edit | edit source]

  1. Wake up
  2. Drink tea
  3. Go shit
  4. Exercise Yoga
  5. Eat breakfast
  6. Backup ALL the files (during hygiene)
  7. Leave home

My external harddrive is totally occupied by a LUKS container. After connecting the drive to my laptop, I start like this:

 cryptsetup luksOpen /dev/sdb backup

If not happened yet, format the drive with a btrfs filesystem

 mkfs.btrfs -L backup /dev/mapper/backup

Then, mount it and use compression

 mount -o compress=lzo -t btrfs LABEL=backup /media/backup

If not happened yet, create a subvolume

 btrfs subvolume create /media/backup/nomaster

For may backups, I use rsync (with delete) to copy my files to an external hard drive. Vanished files will be deleted.

 rsync -aPv --delete --exclude downloads --exclude music --exclude .cache /home/nomaster/ /media/backup/nomaster/

After each sync, I make a snapshot of this state of my files.

 sudo btrfs subvolume snapshot -r /media/backup/nomaster /media/backup/nomaster-$(date +%F)

Lastly, I unmount the filesystem and close the container.

 sudo umount /media
 sudo cryptsetup luksClose backup

Then, I disconnect the drive.

When my drive will be full at some point in the future, I’m going to remove old snapshots to free space occupied by large files deleted a long time ago.

Initial Setup[edit | edit source]

I assume the external drive is /dev/sdb. If you have no idea about this, stop right now and come back when you know.

First, make sure, the external drive is clear to use. So mount it and have a look at the files if present.

Overwrite everything with zeroes.

 sudo dd if=/dev/zero of=/dev/sdb bs=1024

Format the drive

 sudo cryptsetup luksFormat /dev/sdb

(follow the instructions)

Open the crypto container

 sudo cryptsetup luksOpen /dev/sdb backup

Create a BTRFS file system

 sudo mkfs.btrfs /dev/mapper/backup

Mount it (with compression)

 sudo mount -o compress /dev/mapper/backup /mnt

Create a subvolume

 sudo btrfs subvolume create /mnt/nomaster # <- insert username here

Unmount, close and continue with daily routine.

 sudo umount /mnt
 sudo cryptsetup luksClose backup