summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2016-11-09 09:41:50 +0000
committerPatrick J Cherry <patrick@bytemark.co.uk>2016-11-09 09:41:50 +0000
commit3cc8a83938cd4eae9a196375dca2fd9127f23aa0 (patch)
treefa36b507469bdb1c7b4891e336a6928c59bceab5
parent25f3947c16b57a9686500534e44423aab90b0bc7 (diff)
parentc68fe975ab4b47436bd90fa701b83a78793b0f32 (diff)
Merge branch 'master' into 12-fix-btrfs-path
-rw-r--r--.gitignore14
-rw-r--r--README.md71
-rw-r--r--[-rwxr-xr-x]bin/byteback-backup13
-rwxr-xr-xbin/byteback-receive2
-rwxr-xr-xbyteback-mysql/post-backup.d/00-mysql27
-rwxr-xr-xbyteback-mysql/pre-backup.d/00-mysql31
-rwxr-xr-xbyteback-mysql/scripts.d/Bytemyback/ini.pm91
-rwxr-xr-xbyteback-mysql/scripts.d/Bytemyback/lvm80
-rwxr-xr-xbyteback-mysql/scripts.d/Bytemyback/mysqldump-full8
-rwxr-xr-xbyteback-mysql/scripts.d/Bytemyback/mysqldump-split-db44
-rw-r--r--debian/byteback-mysql.install1
-rw-r--r--debian/control11
-rw-r--r--debian/copyright2
-rw-r--r--lib/byteback/backup_directory.rb6
-rw-r--r--rpmbuild/byteback.spec66
15 files changed, 401 insertions, 66 deletions
diff --git a/.gitignore b/.gitignore
index c39506c..3127636 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,12 @@
-debian/byteback.substvars
-debian/byteback
-debian/patches
-debian/files
-debian/byteback.debhelper.log
+*~
\.pc
byteback.sublime-project
byteback.sublime-workspace
-*~
+debian/*.debhelper.log
+debian/*.substvars
+debian/byteback
+debian/byteback-mysql
+debian/debhelper-build-stamp
+debian/files
+debian/patches
man/*.man
diff --git a/README.md b/README.md
index fb10d43..5e43abf 100644
--- a/README.md
+++ b/README.md
@@ -1,42 +1,31 @@
byteback - maintenance-free client & server backup scripts for Linux
====================================================================
-byteback encapsulates Bytemark's "best practice" for maintenance-free backups
+`byteback` encapsulates Bytemark's "best practice" for maintenance-free backups
with easy client and server setup.
-"Maintenance-free" means that we'd rather make full use of a fixed amount of
-disc space. Management of disc space must be completely automatic, so the
-process never grinds to a halt for reasons that could be automatically
-resolved. Failed backups can be restarted in case of network problems.
+"Maintenance-free" means that we'd rather make full use of a fixed amount of disc space. Management of disc space must be completely automatic, so the process never grinds to a halt for reasons that could be automatically resolved. Failed backups can be restarted in case of network problems.
-We use the standard OpenSSH on the server for encrypted transport & access
-control, btrfs for simple snapshots and rsync for efficient data transfer
-across the network.
+We use the standard OpenSSH on the server for encrypted transport & access control, `btrfs` for simple snapshots and `rsync` for efficient data transfer across the network.
+
+Backups should require as little configuration as possible to be safe - just the server address should be enough.
-Backups should require as little configuration as possible to be safe - just
-the server address should be enough.
Setting up: server
------------------
-Install the 'byteback' package on the server, along with its dependencies
-(rsync and ruby-ffi).
+Install the '`byteback`' package on the server, along with its dependencies.
-You then need to perform the following local setup on the server, which can
-securely handle backups for multiple clients. You need a dedicated user
-(which is usually called 'byteback') with a home directory on a btrfs
-filesystem. You will need to mount the filesystem with the
-'user_subvol_rm_allowed' flag to enable pruning to work (or run that part
-as root).
+You then need to perform the following local setup on the server, which can securely handle backups for multiple clients. You need a dedicated user (which is usually called 'byteback') with a home directory on a btrfs filesystem. You will need to mount the filesystem with the '`user_subvol_rm_allowed`' flag to enable pruning to work (or run that part as root).
-The following commands are appropriate for a Debian system, you might need
-to alter it for other Linux distributions, or if you are not using LVM
-for your discs:
+The following commands are appropriate for a Debian system, you might need to alter them for other Linux distributions, or if you are not using LVM for your discs:
+ #
# Create a dedicated UNIX user which will store everyone's backups, and
# allow logins
#
adduser --system byteback --home /byteback --shell /bin/bash
+ #
# Create a dedicated btrfs filesystem for the user, and add that as its home
#
lvcreate my_volume_group --name byteback --size 1000GB
@@ -46,62 +35,53 @@ for your discs:
chown byteback /byteback
chmod u+w /byteback
-Finally, before setting up the client, add
+Finally, before setting up the client you should add the following to `/etc/ssh/sshd_config`, and restart the ssh-service:
PermitUserEnvironment yes
-to /etc/ssh/sshd_config, and restart sshd.
Setting up: client
------------------
-Clients are machines that need to be backed up. Assuming you can log into
-the remote 'byteback' user with a password or administrative key, you only
-need to type one command on the client to set things going:
+Clients are machines that need to be backed up. Assuming you can log into the remote '`byteback`' user with a password or administrative key, you only need to type one command on the client to set things going:
sudo byteback-setup-client --destination byteback@mybackuphost.net:
-If this goes OK, you are ready to start backing up. I'd advise taking the
-first backup manually to make sure it goes as you expect. Type this on the
-client to start and watch the backup.
+If this goes OK, you are ready to start backing up. I'd advise taking the first backup manually to make sure it goes as you expect. Type this on the client to start and watch the backup.
sudo byteback-backup --verbose
+
Configuring byteback-backup
---------------------------
-This is now documented in the manapge for byteback-backup(1).
+This is now documented in the manpage for byteback-backup(1).
+
Viewing and restoring backups
-----------------------------
-This is now documented in the manapge for byteback-restore(1).
+This is now documented in the manpage for byteback-restore(1).
+
The trust model
---------------
-Backups are intended to keep your data safe, and byteback makes the assumption
-that the client may become hostile to the backup server. At Bytemark this
-allows us to guard against rogue employees of our clients destroying the backup,
-while ensuring that our clients can still access all their old backups. There
-are several measures to guard against this, though they are all ineffective
-over a long enough period of time:
+Backups are intended to keep your data safe, and byteback makes the assumption that the client may become hostile to the backup server. At Bytemark this allows us to guard against rogue employees of our clients destroying the backup, while ensuring that our clients can still access all their old backups. There are several measures to guard against this, though they are all ineffective over a long enough period of time:
-* the server uses SSH's command feature to ensure that clients can only
- run rsync to the appropriate directory;
+* the server uses SSH's command feature to ensure that clients can only run rsync to the appropriate directory;
-* the server's snapshots are read-only, so the client can't just rsync an
- empty directory over an old backup;
+* the server's snapshots are read-only, so the client can't just rsync an empty directory over an old backup;
-* the server will refuse to take snapshots "too often" to stop the client
- from filling the disc with useless data;
+* the server will refuse to take snapshots "too often" to stop the client from filling the disc with useless data;
+
+* the server will refuse to prune away space for a new backup that is suddenly larger than previous ones.
-* the server will refuse to prune away space for a new backup that is
- suddenly larger than previous ones.
Pruning behaviour
-----------------
This is now documented in byteback-prune(1).
+
Acknowledgements
----------------
For maximum portability, I've included three libraries. Thanks very much to
@@ -110,4 +90,3 @@ their authors:
* sys-filesystem by Daniel J. Berger: https://github.com/djberg96/sys-filesystem
* trollop by William Morgan: https://github.com/wjessop/trollop
* ffi-xattr by Jari Bakken: https://github.com/jarib/ffi-xattr
-
diff --git a/bin/byteback-backup b/bin/byteback-backup
index 0a50909..8268353 100755..100644
--- a/bin/byteback-backup
+++ b/bin/byteback-backup
@@ -230,11 +230,12 @@ if __FILE__ == $PROGRAM_NAME
COMMON_JUNK = %w(
/swap.file
- /tmp
- /var/backups/localhost
- /var/cache/apt/archives
- /var/lib/php5
- /var/tmp
+ /tmp/
+ /var/backups/localhost/
+ /var/cache/apt/archives/
+ /var/lib/php5/
+ /var/tmp/
+ /var/lib/mysql/
)
MOUNT_HEADINGS = %w( spec file vfstype mntops freq passno ).map(&:to_sym)
@@ -253,7 +254,7 @@ if __FILE__ == $PROGRAM_NAME
e.gsub(/\/+/, '/')
end
- fatal('Must suply --destination or put it into /etc/bytebackup/destination') unless @destination
+ fatal('Must supply --destination or put it into /etc/bytebackup/destination') unless @destination
#
# Test that we have an SSH-key which we can read.
diff --git a/bin/byteback-receive b/bin/byteback-receive
index 0d7d025..1326bba 100755
--- a/bin/byteback-receive
+++ b/bin/byteback-receive
@@ -116,7 +116,7 @@ end
# Make sure we don't get crazy option combinations.
#
n_modes = opts.keys.inject(0) do |s,m|
- s += 1 if [:ping, :complete, :list].include?(m)
+ [:ping, :complete, :list].include?(m) ? s += 1 : s
end
error('Please only choose one mode') unless n_modes == 1
diff --git a/byteback-mysql/post-backup.d/00-mysql b/byteback-mysql/post-backup.d/00-mysql
new file mode 100755
index 0000000..72369bf
--- /dev/null
+++ b/byteback-mysql/post-backup.d/00-mysql
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use lib '/etc/byteback/scripts.d';
+use Bytemyback::ini qw(readconf writeconf generateconf);
+
+use Sys::Hostname;
+
+# Shim script to determine which MySQL backup(s) to run if any
+
+my %config = Bytemyback::ini::readconf();
+
+my $backup_method = $config{'backup_method'};
+
+foreach my $method (keys %$backup_method) {
+ next unless $backup_method->{$method};
+ print "Running /etc/byteback/scripts.d/Bytemyback/${method} post\n";
+ `/etc/byteback/scripts.d/Bytemyback/${method} post` if (-x "/etc/byteback/scripts.d/Bytemyback/${method}");
+ print "Finished /etc/byteback/scripts.d/Bytemyback/${method} post\n";
+
+ # Each script should have a heartbeat alert. They may also have specific failure alerts on both client and
+ # server side.
+ my $host = hostname;
+ system("mauvesend -i $method-hb-${host}-low -c now -r +26h -s 'MySQL backup method $method on ${host} has not run for over a day' --detail='Please try running manually to see what the problem was, and check the mailing list'");
+}
diff --git a/byteback-mysql/pre-backup.d/00-mysql b/byteback-mysql/pre-backup.d/00-mysql
new file mode 100755
index 0000000..edfcd56
--- /dev/null
+++ b/byteback-mysql/pre-backup.d/00-mysql
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use Data::Dumper;
+
+use lib '/etc/byteback/scripts.d';
+use Bytemyback::ini qw(readconf writeconf generateconf);
+
+# Shim script to determine which MySQL backup(s) to run if any
+
+my %config = Bytemyback::ini::readconf();
+if (!%config) {
+ %config = Bytemyback::ini::generateconf();
+}
+
+# Backup directory shouldn't be world-readable
+system("mkdir -p /var/backups/byteback");
+system("chmod 700 /var/backups/byteback");
+
+# List of each script to run (not mutually exclusive). Generated automatically if it doesn't exist
+
+my $backup_method = $config{'backup_method'};
+
+foreach my $method (keys %$backup_method) {
+ next unless $backup_method->{$method};
+ print "Running /etc/byteback/scripts.d/Bytemyback/${method} pre\n";
+ `/etc/byteback/scripts.d/Bytemyback/${method} pre` if (-x "/etc/byteback/scripts.d/Bytemyback/${method}");
+ print "Finished /etc/byteback/scripts.d/Bytemyback/${method} pre\n";
+}
diff --git a/byteback-mysql/scripts.d/Bytemyback/ini.pm b/byteback-mysql/scripts.d/Bytemyback/ini.pm
new file mode 100755
index 0000000..74b1fc7
--- /dev/null
+++ b/byteback-mysql/scripts.d/Bytemyback/ini.pm
@@ -0,0 +1,91 @@
+#!/usr/bin/perl
+
+package Bytemyback::ini;
+
+use warnings;
+use strict;
+
+use Data::Dumper;
+
+use Exporter;
+our @EXPORT_OK = qw(readconf writeconf generateconf);
+
+# Didn't want to have to install any libraries on all servers.
+# Couldn't find anything default and lightweight to read ini files
+# So wrote this. Sorry.
+
+sub readconf {
+ my $file = shift || '/etc/byteback/mysql.ini';
+ my %config;
+ my $subsection = "default";
+ return if !$file;
+ open my $fh, "<", $file or return;
+ foreach (<$fh>) {
+ if (/^\s*\[([^\]]+)\]/) {
+ $subsection = $1;
+ }
+ elsif (/^\s*(\S[^\s=]*)\s*=\s*(\S[^\s=]*)\s*$/) {
+ $config{$subsection}->{$1}=$2;
+ }
+ }
+ close $fh;
+ return %config;
+}
+
+sub writeconf {
+ # Hate writing code like this. @_ is the list of arguments passed to
+ # this subroutine. It's either a file and a hash, or just a hash. A
+ # hash is passed as a list of pairs of arguments (and Perl puts them
+ # back into a hash). When used in scalar context, @_ returns the number
+ # of items in the array. @_ % 2 is the remainder when this is divided by
+ # 2 (modulo). So if it's either 1 if there are an odd number of elements
+ # or 0. Perl treats 1 as true, 0 as false. So this one line with 10 lines
+ # of explanation say if there are an odd number of elements, the first is
+ # the ini file and should be shifted (removed from the front), otherwise
+ # use a default.
+ my $config_file = @_ % 2 ? shift : '/etc/byteback/mysql.ini';
+ my %config = @_;
+ open my $fh, ">", $config_file;
+ foreach my $subsection (keys %config) {
+ print $fh "[$subsection]\n";
+ my $href = $config{$subsection};
+ foreach my $key (keys %$href) {
+ print $fh $key, " = ", $href->{$key}, "\n";
+ }
+ }
+ close $fh;
+}
+
+sub generateconf {
+ # Wipes current config, tries to figure out a set of defaults.
+ # set LVM to 1 only if /etc/lvmbackup.conf exists
+ # If it does, also populate LV size and whether or not to lock from there
+ my %backup_method = ( "lvm", 0, "mysqldump-split-db", 0, "mysqldump-full", 1 );
+ # LVM specific variables
+ my %lvm;
+ # By default, lock tables. May be overridden below.
+ $lvm{"lock"} = 1;
+ my $lvmconfig = '/etc/mylvmbackup.conf';
+ if (-e $lvmconfig) {
+ my $failed = 0;
+ open my $conffh, "<", "/etc/mylvmbackup.conf" or $failed++;
+ if ($conffh) {
+ foreach (<$conffh>) {
+ if (/^\s*lvsize=(\S+)\s*$/) {
+ $lvm{"lvsize"} = $1;
+ }
+ if (/^\s*skip_flush_tables=1/) {
+ $lvm{"lock"} = 0;
+ }
+ }
+ close $conffh;
+ }
+ $backup_method{"lvm"} = 1;
+ }
+ else {
+ $backup_method{"mysqldump-full"} = 1;
+ }
+ my %config = ( "backup_method" => \%backup_method, "lvm" => \%lvm );
+ writeconf(%config);
+ return(%config);
+}
diff --git a/byteback-mysql/scripts.d/Bytemyback/lvm b/byteback-mysql/scripts.d/Bytemyback/lvm
new file mode 100755
index 0000000..c3ff4fb
--- /dev/null
+++ b/byteback-mysql/scripts.d/Bytemyback/lvm
@@ -0,0 +1,80 @@
+#!/usr/bin/perl
+
+use DBI;
+use Data::Dumper;
+
+use warnings;
+use strict;
+
+my $mountpoint = "/var/backups/bytemyback/mnt/";
+my $snapshot_name = "byteback_data_snap";
+my $snapshot_size = "20G";
+my $dbh;
+
+die "Must specify either pre or post\n" unless @ARGV;
+
+if ($ARGV[0] eq 'pre') {
+ # Check snapshot doesn't already exist
+ die "Snapshot still exists\n" if `lvs 2>&1` =~ /$snapshot_name/;
+ my $lock_tables = 1; # This will be configurable. Whether or not it runs FLUSH TABLES WITH READ LOCK before taking the snapshot.
+ my $defaults_file = '/etc/mysql/debian.cnf';
+ my $dsn = "DBI:mysql:;mysql_read_default_file=$defaults_file";
+ $dbh = DBI->connect(
+ $dsn,
+ undef,
+ undef,
+ {RaiseError => 1}
+ ) or die "DBI::errstr: $DBI::errstr";
+
+ my $data_dir = ask_mysql_for_var('datadir');
+ my $lvm_dir = get_LVM_dir();
+ die "MySQL doesn't seem to be running from LVM\n" if !$lvm_dir;
+ $dbh->do("FLUSH TABLES WITH READ LOCK") if $lock_tables;
+ # Create snapshot
+ my $mounted_lvm = `df $lvm_dir | tail -n1 | cut -f1 -d" "`;
+ if (!`lvcreate -n $snapshot_name -L $snapshot_size --snapshot $mounted_lvm`) {
+ my $error = $!;
+ $dbh->do("UNLOCK TABLES") if $lock_tables;
+ die("Unable to create snapshot: $!\n");
+ }
+ else {
+ $dbh->do("UNLOCK TABLES") if $lock_tables;
+ chomp (my $mapped_snapshot = "/dev/mapper/" . `dmsetup ls | grep $snapshot_name | grep -v cow | cut -f1 -d " "`);
+ `mkdir -p $mountpoint`;
+ `mount $mapped_snapshot $mountpoint`;
+ `touch ${mountpoint}.bytebacklvm`;
+ }
+}
+elsif ($ARGV[0] eq 'post') {
+ `umount $mountpoint`;
+ chomp (my $mapped_snapshot = "/dev/mapper/" . `dmsetup ls | grep $snapshot_name | grep -v cow | cut -f1 -d " "`);
+ `lvremove -f $mapped_snapshot`;
+}
+
+sub ask_mysql_for_var {
+ my $var = '@@' . shift;
+ my $query = $dbh->prepare("SELECT ${var}");
+ $query->execute;
+ return $query->fetchrow_hashref()->{$var};
+}
+
+sub get_LVM_dir {
+ # This is a bit hacky, it checks if lvs returns,
+ # then checks if the mountpoint is /dev/mapper/$firstbit-$secondbit
+ # Returns true only if above matches and lvs output has $secondbit $firstbit somewhere
+ my $datadir = ask_mysql_for_var('datadir');
+ my $lvs = `lvs 2>&1`;
+ if (($?) || ($lvs =~ /No volume groups found/)) {
+ return 0;
+ }
+ my $output = `df $datadir | tail -n1`;
+ $output =~ s/--/:/g;
+ if ($output =~ m#/dev/mapper/([\w:]+)-([\w:]+)\s#) {
+ my ($vg, $lv) = ($1, $2);
+ $vg =~ s/:/-/; $lv =~ s/:/-/;
+ if ($lvs =~ /\s+$lv\s+$vg\s/) {
+ return $datadir;
+ }
+ }
+ return 0;
+}
diff --git a/byteback-mysql/scripts.d/Bytemyback/mysqldump-full b/byteback-mysql/scripts.d/Bytemyback/mysqldump-full
new file mode 100755
index 0000000..b4bb01e
--- /dev/null
+++ b/byteback-mysql/scripts.d/Bytemyback/mysqldump-full
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+if [ "$1" == "pre" ]; then
+ HOST=`hostname`
+ echo "Dumping all databases into one backup file"
+ mkdir -p /var/backups/byteback/mysqldump-full
+ mysqldump --defaults-file=/etc/mysql/debian.cnf -A --events | gzip > /var/backups/byteback/mysqldump-full/dump.sql.gz && mauvesend -i mysqldump-split-${HOST}-low -c now -r +30h -s "mysqldump on ${HOST} has not run for over a day" --detail='Please try running manually to see what the problem was, and check the mailing list'
+fi
diff --git a/byteback-mysql/scripts.d/Bytemyback/mysqldump-split-db b/byteback-mysql/scripts.d/Bytemyback/mysqldump-split-db
new file mode 100755
index 0000000..b484ef6
--- /dev/null
+++ b/byteback-mysql/scripts.d/Bytemyback/mysqldump-split-db
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use Sys::Hostname;
+
+if ((!@ARGV) or ($ARGV[0] ne 'pre')) {
+ exit;
+}
+
+# Quick mysqldump wrapper to dump individual databases and alert if it fails at all
+my $failed = 0; # only set to 0 once
+my $failed_databases = '';
+my $backup_directory = '/var/backups/byteback/mysqldump-split-db/';
+`mkdir -p $backup_directory`;
+
+my @databases = `echo "SHOW DATABASES" | mysql --defaults-file=/etc/mysql/debian.cnf`;
+shift @databases; # Get rid of 'Databases' title from the top
+foreach my $database (@databases) {
+ chomp($database);
+ next if $database eq "lost+found";
+ next if $database =~ /^#mysql..#lost\+found$/;
+ next if $database =~ /^information_schema$/;
+ next if $database =~ /^performance_schema$/;
+ next if $database =~ /^events$/;
+ next if $database =~ /^cond_instances$/;
+ print "Dumping $database\n";
+ # Need to get rid of this -f once we've fixed errors with views (access denied etc.)
+ my $gzip = -x '/usr/bin/pigz' ? '/usr/bin/pigz' : 'gzip';
+ my $error_code = system("mysqldump --defaults-file=/etc/mysql/debian.cnf --events -f $database | $gzip > ${backup_directory}/${database}.sql.gz\n");
+ if ($error_code) {
+ $failed++;
+ $failed_databases .= " $database";
+ }
+}
+
+my $host = hostname;
+if ($failed) {
+ $host = hostname;
+ system("mauvesend -i mysqldump-${host}-low -r now -s 'mysqldump on ${host} failed for $failed_databases' --detail='Please try running them manually to see what the problem was, and check the mailing list'");
+}
+else {
+ system("mauvesend -i mysqldump-${host}-low -c now -s 'mysqldump on ${host} failed for $failed_databases' --detail='Please try running them manually to see what the problem was, and check the mailing list'");
+}
diff --git a/debian/byteback-mysql.install b/debian/byteback-mysql.install
new file mode 100644
index 0000000..9cb72b5
--- /dev/null
+++ b/debian/byteback-mysql.install
@@ -0,0 +1 @@
+byteback-mysql/* etc/byteback/
diff --git a/debian/control b/debian/control
index 7c17d0e..8623f60 100644
--- a/debian/control
+++ b/debian/control
@@ -6,8 +6,8 @@ Uploaders: Steve Kemp <steve@bytemark.co.uk>
Build-Depends: debhelper (>= 7.0.50~), txt2man
Standards-Version: 3.9.6
# Vcs-Git:
-Vcs-Browser: https://projects.bytemark.co.uk/projects/byteback/repository
-Homepage: https://projects.bytemark.co.uk/projects/byteback
+Vcs-Browser: https://github.com/BytemarkHosting/byteback.git
+Homepage: https://github.com/BytemarkHosting/byteback
Package: byteback
Architecture: all
@@ -27,3 +27,10 @@ Description: Maintenance-free client & server backup scripts for Linux
.
Backups should require as little configuration as possible to be safe - just
the server address should be enough.
+
+Package: byteback-mysql
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, perl, libdbi-perl,
+Description: Maintenance-free backups for MySQL
+ leveraging byteback this package allows simple and transparent
+ backups of MySQL databases.
diff --git a/debian/copyright b/debian/copyright
index 9dbafb4..c9616c0 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,6 +1,6 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: byteback
-Source: <https://projects.bytemark.co.uk/projects/byteback>
+Source: <https://github.com/BytemarkHosting/byteback>
Files: lib/trollop.rb
Copyright:: 2007 William Morgan <wmorgan-trollop@masanjin.net>
diff --git a/lib/byteback/backup_directory.rb b/lib/byteback/backup_directory.rb
index 53491ff..a39cf84 100644
--- a/lib/byteback/backup_directory.rb
+++ b/lib/byteback/backup_directory.rb
@@ -155,8 +155,7 @@ module Byteback
next if entry[0] == '.'
name = File.expand_path(ENV['HOME'] + '/' + entry)
File.directory?(name + '/current') ? BackupDirectory.new(name) : nil
- end
- .compact
+ end.compact
end
# Returns every snapshot in every backup directory
@@ -195,8 +194,7 @@ module Byteback
# directory name must represent a parseable Time
nil
end
- end
- .compact
+ end.compact
end
# Create a new snapshot of 'current'
diff --git a/rpmbuild/byteback.spec b/rpmbuild/byteback.spec
new file mode 100644
index 0000000..58841be
--- /dev/null
+++ b/rpmbuild/byteback.spec
@@ -0,0 +1,66 @@
+Name: byteback
+Version: 0.4.2
+Release: 1%{?dist}
+Summary: Maintenance-free client & server backup scripts for Linux
+
+Group: Applications/System
+License: Ruby and GPLv2+ and ASL 2.0 and Artistic 2.0
+URL: https://github.com/BytemarkHosting/byteback
+Source0: byteback_%{version}.orig.tar.gz
+
+BuildArch: noarch
+BuildRequires: txt2man
+Requires: openssh-clients
+Requires: ruby
+Requires: rubygem-ffi
+Requires: rsync
+
+%description
+byteback encapsulates Bytemark's "best practice" for maintenance-free backups
+with easy client and server setup.
+
+"Maintenance-free" means that we'd rather make full use of a fixed amount of
+disc space. Management of disc space must be completely automatic, so the
+process never grinds to a halt for reasons that could be automatically
+resolved. Failed backups can be restarted in case of network problems.
+
+We use the standard OpenSSH on the server for encrypted transport & access
+control, btrfs for simple snapshots and rsync for efficient data transfer
+across the network.
+
+Backups should require as little configuration as possible to be safe - just
+the server address should be enough.
+
+
+%prep
+%setup -q -c
+# No binary files, so should go in /usr/share.
+sed -i -e 's|/usr/lib/byteback|/usr/share/byteback|g' bin/*
+# Required to load system gems.
+sed -i -e "2irequire 'rubygems'" bin/*
+
+
+%build
+make docs
+
+
+%install
+mkdir -p %{buildroot}%{_bindir}
+cp -a bin/* %{buildroot}%{_bindir}/
+
+mkdir -p %{buildroot}%{_datadir}/byteback
+cp -a lib/* %{buildroot}%{_datadir}/byteback/
+
+mkdir -p %{buildroot}%{_mandir}/man1
+for i in man/*.man; do
+ mv $i ${i%%.man}.1
+done;
+cp -a man/*.1 %{buildroot}%{_mandir}/man1/
+
+
+%files
+%doc README.md
+%{_bindir}/*
+%{_datadir}/byteback
+%{_mandir}/man1/*.1*
+