Locked History Actions

ServerInfo/FileSystem

File System Notes

Setup

Use parted to build partition table.

$ sudo parted /dev/sdb
GNU Parted 2.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) rm 1                                                             
(parted) mkpart logical 1 -1                                              
(parted) print
Model: DELL PERC H700 (scsi)
Disk /dev/sdb: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  2000GB  2000GB               logical

(parted) quit                                                             
Information: You may need to update /etc/fstab.                           

Build ext4 filesystem using mkfs.

$ sudo mkfs -t ext4 /dev/sdb1 
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
122060800 inodes, 488242688 blocks
24412134 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
14900 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000, 214990848

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Create mount point and mount:

$ sudo mkdir /backup
$ sudo mount -t ext4 /dev/sdb1 /backup

Repeat for data volume. Then add the following to /etc/fstab :

/dev/sdb1       /backup         ext4    defaults        0       2
/dev/sdc1       /data           ext4    defaults        0       2

Backups

Automated backups are done using the rdiff-backup tool.

I started off by just taking one snapshot of the /home directory. You can play around by creating and restoring backups in your own home directory.

TODO:

  • Actually set up automated backups. Probably need to use cron.
  • Figure out exclude lists. Which directories do not need to be backed up? For example --exclude /proc --exclude /tmp

  • Look into how file permissions are preserved.
  • Can a user restore their own files?

Install package:

sudo apt-get install rdiff-backup

Create a backup:

rdiff-backup /dir /backup/dir

Restore a single file:

rdiff-backup --restore-as-of now /backup/dir/path/to/file /dir/path/to/file

Or a bit shorter:

rdiff-backup -r /backup/dir/path/to/file /dir/path/to/file

Note that you can specify any location to restore to. Also, instead of now you can use any digit followed by s, m, h, D, W, M,  or  Y. For example, if you want to restore a file as it was 3 days ago but don't want to overwrite the current version:

rdiff-backup --restore-as-of 3D /backup/dir/path/to/file /dir/path/to/file_old

Those are the basic commands. You can do other things like verify the backups and look up various statistics. See the man page for details.

List of directories to backup stored in /backup/backup-list. Contents:

/etc
/usr
/home
/var
/root
/srv/gitosis

Added the following line to root's crontab (sudo crontab -e):

@hourly /usr/bin/rdiff-backup --include-globbing-filelist /backup/backup-list --exclude '**' / /backup/darkmatter

To view backup statistics:

$ sudo sh -c "rdiff-backup --calculate-average /backup/darkmatter/rdiff-backup-data/session_statistics*"