initial revision:
basic packaging
code import from Mike Rubel's page (see copyright)
This commit is contained in:
commit
9584e5d415
3
.bzrignore
Normal file
3
.bzrignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.ex
|
||||||
|
*.EX
|
||||||
|
.bzr-builddeb
|
||||||
5
debian/changelog
vendored
Normal file
5
debian/changelog
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
remote-backup (1.0) unstable; urgency=low
|
||||||
|
|
||||||
|
* Initial Release.
|
||||||
|
|
||||||
|
-- Vincent Riquer <v.riquer@b2f-concept.com> Thu, 19 Nov 2009 14:48:17 +0100
|
||||||
1
debian/compat
vendored
Normal file
1
debian/compat
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
7
|
||||||
13
debian/control
vendored
Normal file
13
debian/control
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Source: remote-backup
|
||||||
|
Section: unknown
|
||||||
|
Priority: extra
|
||||||
|
Maintainer: Vincent Riquer <v.riquer@b2f-concept.com>
|
||||||
|
Build-Depends: debhelper (>= 7)
|
||||||
|
Standards-Version: 3.7.3
|
||||||
|
Homepage: <insert the upstream URL, if relevant>
|
||||||
|
|
||||||
|
Package: remote-backup
|
||||||
|
Architecture: any
|
||||||
|
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||||
|
Description: <insert up to 60 chars description>
|
||||||
|
<insert long description, indented with spaces>
|
||||||
39
debian/copyright
vendored
Normal file
39
debian/copyright
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
This package was debianized by Vincent Riquer <v.riquer@b2f-concept.com> on
|
||||||
|
Thu, 19 Nov 2009 14:48:17 +0100.
|
||||||
|
|
||||||
|
It was downloaded from http://www.mikerubel.org/computers/rsync_snapshots/
|
||||||
|
|
||||||
|
Upstream Author:
|
||||||
|
|
||||||
|
Mike Rubel <mrubel@caltech.edu>
|
||||||
|
|
||||||
|
Copyright:
|
||||||
|
|
||||||
|
Copyright (C) 2004 Mike Rubel
|
||||||
|
Copyright (C) 2009 Vincent Riquer <v.riquer@b2f-concept.com>
|
||||||
|
|
||||||
|
License:
|
||||||
|
|
||||||
|
This package is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This package is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this package; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
On Debian systems, the complete text of the GNU General
|
||||||
|
Public License can be found in `/usr/share/common-licenses/GPL'.
|
||||||
|
|
||||||
|
The Debian packaging is (C) 2009, Vincent Riquer <v.riquer@b2f-concept.com> and
|
||||||
|
is licensed under the GPL, see above.
|
||||||
|
|
||||||
|
|
||||||
|
# Please also look if there are files or directories which have a
|
||||||
|
# different copyright/license attached and list them here.
|
||||||
2
debian/dirs
vendored
Normal file
2
debian/dirs
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
usr/bin
|
||||||
|
usr/sbin
|
||||||
0
debian/docs
vendored
Normal file
0
debian/docs
vendored
Normal file
91
debian/rules
vendored
Executable file
91
debian/rules
vendored
Executable file
@ -0,0 +1,91 @@
|
|||||||
|
#!/usr/bin/make -f
|
||||||
|
# -*- makefile -*-
|
||||||
|
# Sample debian/rules that uses debhelper.
|
||||||
|
# This file was originally written by Joey Hess and Craig Small.
|
||||||
|
# As a special exception, when this file is copied by dh-make into a
|
||||||
|
# dh-make output file, you may use that output file without restriction.
|
||||||
|
# This special exception was added by Craig Small in version 0.37 of dh-make.
|
||||||
|
|
||||||
|
# Uncomment this to turn on verbose mode.
|
||||||
|
#export DH_VERBOSE=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
configure: configure-stamp
|
||||||
|
configure-stamp:
|
||||||
|
dh_testdir
|
||||||
|
# Add here commands to configure the package.
|
||||||
|
|
||||||
|
touch configure-stamp
|
||||||
|
|
||||||
|
|
||||||
|
build: build-stamp
|
||||||
|
|
||||||
|
build-stamp: configure-stamp
|
||||||
|
dh_testdir
|
||||||
|
|
||||||
|
# Add here commands to compile the package.
|
||||||
|
$(MAKE)
|
||||||
|
#docbook-to-man debian/remote-backup.sgml > remote-backup.1
|
||||||
|
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
dh_testdir
|
||||||
|
dh_testroot
|
||||||
|
rm -f build-stamp configure-stamp
|
||||||
|
|
||||||
|
# Add here commands to clean up after the build process.
|
||||||
|
$(MAKE) clean
|
||||||
|
|
||||||
|
dh_clean
|
||||||
|
|
||||||
|
install: build
|
||||||
|
dh_testdir
|
||||||
|
dh_testroot
|
||||||
|
dh_clean -k
|
||||||
|
dh_installdirs
|
||||||
|
|
||||||
|
# Add here commands to install the package into debian/remote-backup.
|
||||||
|
$(MAKE) DESTDIR=$(CURDIR)/debian/remote-backup install
|
||||||
|
|
||||||
|
|
||||||
|
# Build architecture-independent files here.
|
||||||
|
binary-indep: build install
|
||||||
|
# We have nothing to do by default.
|
||||||
|
|
||||||
|
# Build architecture-dependent files here.
|
||||||
|
binary-arch: build install
|
||||||
|
dh_testdir
|
||||||
|
dh_testroot
|
||||||
|
dh_installchangelogs
|
||||||
|
dh_installdocs
|
||||||
|
dh_installexamples
|
||||||
|
# dh_install
|
||||||
|
# dh_installmenu
|
||||||
|
# dh_installdebconf
|
||||||
|
# dh_installlogrotate
|
||||||
|
# dh_installemacsen
|
||||||
|
# dh_installpam
|
||||||
|
# dh_installmime
|
||||||
|
# dh_python
|
||||||
|
# dh_installinit
|
||||||
|
# dh_installcron
|
||||||
|
# dh_installinfo
|
||||||
|
dh_installman
|
||||||
|
dh_link
|
||||||
|
dh_strip
|
||||||
|
dh_compress
|
||||||
|
dh_fixperms
|
||||||
|
# dh_perl
|
||||||
|
# dh_makeshlibs
|
||||||
|
dh_installdeb
|
||||||
|
dh_shlibdeps
|
||||||
|
dh_gencontrol
|
||||||
|
dh_md5sums
|
||||||
|
dh_builddeb
|
||||||
|
|
||||||
|
binary: binary-indep binary-arch
|
||||||
|
.PHONY: build clean binary-indep binary-arch binary install configure
|
||||||
88
remote-backup
Normal file
88
remote-backup
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# mikes handy rotating-filesystem-snapshot utility
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
# this needs to be a lot more general, but the basic idea is it makes
|
||||||
|
# rotating backup-snapshots of /home whenever called
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
unset PATH # suggestion from H. Milz: avoid accidental use of $PATH
|
||||||
|
|
||||||
|
# ------------- system commands used by this script --------------------
|
||||||
|
ID=/usr/bin/id;
|
||||||
|
ECHO=/bin/echo;
|
||||||
|
|
||||||
|
MOUNT=/bin/mount;
|
||||||
|
RM=/bin/rm;
|
||||||
|
MV=/bin/mv;
|
||||||
|
CP=/bin/cp;
|
||||||
|
TOUCH=/bin/touch;
|
||||||
|
|
||||||
|
RSYNC=/usr/bin/rsync;
|
||||||
|
|
||||||
|
|
||||||
|
# ------------- file locations -----------------------------------------
|
||||||
|
|
||||||
|
MOUNT_DEVICE=/dev/hdb1;
|
||||||
|
SNAPSHOT_RW=/root/snapshot;
|
||||||
|
EXCLUDES=/usr/local/etc/backup_exclude;
|
||||||
|
|
||||||
|
|
||||||
|
# ------------- the script itself --------------------------------------
|
||||||
|
|
||||||
|
# make sure we're running as root
|
||||||
|
if (( `$ID -u` != 0 )); then { $ECHO "Sorry, must be root. Exiting..."; exit; } fi
|
||||||
|
|
||||||
|
# attempt to remount the RW mount point as RW; else abort
|
||||||
|
$MOUNT -o remount,rw $MOUNT_DEVICE $SNAPSHOT_RW ;
|
||||||
|
if (( $? )); then
|
||||||
|
{
|
||||||
|
$ECHO "snapshot: could not remount $SNAPSHOT_RW readwrite";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
fi;
|
||||||
|
|
||||||
|
|
||||||
|
# rotating snapshots of /home (fixme: this should be more general)
|
||||||
|
|
||||||
|
# step 1: delete the oldest snapshot, if it exists:
|
||||||
|
if [ -d $SNAPSHOT_RW/home/hourly.3 ] ; then \
|
||||||
|
$RM -rf $SNAPSHOT_RW/home/hourly.3 ; \
|
||||||
|
fi ;
|
||||||
|
|
||||||
|
# step 2: shift the middle snapshots(s) back by one, if they exist
|
||||||
|
if [ -d $SNAPSHOT_RW/home/hourly.2 ] ; then \
|
||||||
|
$MV $SNAPSHOT_RW/home/hourly.2 $SNAPSHOT_RW/home/hourly.3 ; \
|
||||||
|
fi;
|
||||||
|
if [ -d $SNAPSHOT_RW/home/hourly.1 ] ; then \
|
||||||
|
$MV $SNAPSHOT_RW/home/hourly.1 $SNAPSHOT_RW/home/hourly.2 ; \
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# step 3: make a hard-link-only (except for dirs) copy of the latest snapshot,
|
||||||
|
# if that exists
|
||||||
|
if [ -d $SNAPSHOT_RW/home/hourly.0 ] ; then \
|
||||||
|
$CP -al $SNAPSHOT_RW/home/hourly.0 $SNAPSHOT_RW/home/hourly.1 ; \
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# step 4: rsync from the system into the latest snapshot (notice that
|
||||||
|
# rsync behaves like cp --remove-destination by default, so the destination
|
||||||
|
# is unlinked first. If it were not so, this would copy over the other
|
||||||
|
# snapshot(s) too!
|
||||||
|
$RSYNC \
|
||||||
|
-va --delete --delete-excluded \
|
||||||
|
--exclude-from="$EXCLUDES" \
|
||||||
|
/home/ $SNAPSHOT_RW/home/hourly.0 ;
|
||||||
|
|
||||||
|
# step 5: update the mtime of hourly.0 to reflect the snapshot time
|
||||||
|
$TOUCH $SNAPSHOT_RW/home/hourly.0 ;
|
||||||
|
|
||||||
|
# and thats it for home.
|
||||||
|
|
||||||
|
# now remount the RW snapshot mountpoint as readonly
|
||||||
|
|
||||||
|
$MOUNT -o remount,ro $MOUNT_DEVICE $SNAPSHOT_RW ;
|
||||||
|
if (( $? )); then
|
||||||
|
{
|
||||||
|
$ECHO "snapshot: could not remount $SNAPSHOT_RW readonly";
|
||||||
|
exit;
|
||||||
|
} fi;
|
||||||
Loading…
x
Reference in New Issue
Block a user