Rdiff - moduli


Rdiff - Asentaa rdiff-backup:n. Mounttaa halutun laitteen (esim. /dev/sdb1) haluttuun kansioon. Ottaa varmuuskopiot määritetystä kansiosta kerran yössä.


Ladattavissa täältä.

Käyttöjärjestelmät:

Testattu seuraavilla käyttöjärjestelmillä:


Xubuntu 12.10 32-bit

Ubuntu 12.04 LTS 64-bit

Debian 6.0 64-bit


Rakenne:

rdiff
├── manifests
│   ├── backup.pp
│   ├── init.pp
│   └── install.pp
└── README

README

########################
# Puppet module: rdiff #
########################

This module installs rdiff-backup, mounts specified device and takes backups.

#####################
# TODO before using #
#####################

Check rdiff::backup for wanted schedule.

Default schedule:
1 backup per day between 2 and 4 am.
Cleares 6 month and older backups.

################
# Sample usage #
################

rdiff::backup { '/var/www/mysite.com':
        mount_dest      => '/mnt/backups',
        dev             => '/dev/sdc1',
        backup_dest_dir => 'mysite.com',
}

##########
# Author #
##########

Made by Sampo Tyllilä <sampo.tyllila@gmail.com>

###########
# License #
###########

This software is distributed under the GNU General Public License version 2 or any later version.
http://www.gnu.org/licenses/

Manifests kansion sisältö:


init.pp

# == Class: rdiff
#
# This module manages mounting specified devices and taking backups with rdiff.
#
# === Parameters
#
# There are no default parameters for this class. All module parameters are managed
# via the rdiff::params class.
#
# === Examples
#
# See README for details.
#
# === Author
#
# Sampo Tyllilä 
#
class rdiff {
        include rdiff::install
}

install.pp

# == Class: rdiff::install
#
# This class installs rdiff-backup.
#
# === Author
#
# Sampo Tyllilä 
#
class rdiff::install {
        package { 'rdiff-backup':
                ensure => latest,
        }
}

backup.pp

# == Define: rdiff::backup
#
# This class mounts specified device to specified location
# and takes backups to the destination once a day.
#
# === Parameters
#
# [*backup_from*]      - The location where the backups are wanted from.
# [*mount_dest*]       - The destination where to mount specified device.
# [*dev*]              - The device to mount.
# [*backup_dest_dir*]  - The location where the backups are taken to.
# [*backup_dir_owner*] - The owner of the backup directory.
# [*backup_dir_perm*]  - The permissions to the backup directory.
#
# === Author
#
# Sampo Tyllilä 
#
define rdiff::backup (
        $backup_from,
        $mount_dest,
        $dev,
        $backup_dest_dir,
        $backup_dir_owner = 'root',
        $backup_dir_perm  = '700'
)       {

        include rdiff

        file { $mount_dest:
                ensure  => directory,
                replace => false,
        }

        mount { $mount_dest:
                device  => $dev,
                fstype  => 'auto',
                ensure  => mounted,
                options => 'defaults',
                atboot  => true,
                require => File[$mount_dest],
        }

        file { "${mount_dest}/${backup_dest_dir}":
                ensure  => directory,
                replace => false,
                owner   => $backup_dir_owner,
                group   => $backup_dir_owner,
                mode    => $backup_dir_perm,
                require => Mount[$mount_dest],
        }

        schedule { 'backup':
                range  => "2 - 4",
                period => daily,
                repeat => 1,
        }

        exec { "/usr/bin/rdiff-backup -b ${backup_from} ${mount_dest}/${backup_dest_dir}":
                schedule => 'backup',
        }

        exec { "/usr/bin/rdiff-backup --remove-older-than 6M ${mount_dest}/${backup_dest_dir}":
                schedule => 'backup',
        }

}

Huomioita.

Modulin rakenne on hieman pielessä vielä. Kuten sisällöstä näkee, niin dyfi-update daemonin asennus tapahtuu config.pp:ssä, eikä install.pp:ssä.