Giter Site home page Giter Site logo

autosnap-rbd-shadow-copy's Introduction

autosnap-rbd-shadow-copy

This script make snapshot on Ceph RBD device and mount them for use with Samba vfs shadow_copy2.

How to use

For test, you need to have a Ceph cluster running and Samba installed on client.

Verify admin access to the ceph cluster : (should not return error)

$ rbd ls

Installation

Get this script :

$ mkdir -p /etc/ceph/scripts/
$ cd /etc/ceph/scripts/
$ wget https://raw.github.com/ksperis/autosnap-rbd-shadow-copy/master/autosnap.conf
$ wget https://raw.github.com/ksperis/autosnap-rbd-shadow-copy/master/autosnap.sh
$ chmod +x autosnap.sh

Prepare rbd block device

Create a block device :

$ rbd create myshare --size=1024
$ echo "myshare" >> /etc/ceph/rbdmap
$ /etc/init.d/rbdmap reload
[ ok ] Starting RBD Mapping: rbd/myshare.
[ ok ] Mounting all filesystems...done.

Format the block device :

$ mkfs.xfs /dev/rbd/rbd/myshare
log stripe unit (4194304 bytes) is too large (maximum is 256KiB)
log stripe unit adjusted to 32KiB
meta-data=/dev/rbd/rbd/myshare   isize=256    agcount=9, agsize=31744 blks
         =                       sectsz=512   attr=2, projid32bit=0
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=1024   swidth=1024 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=8 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

Mount the share

$ mkdir /myshare
$ echo "/dev/rbd/rbd/myshare /myshare xfs defaults 0 0" >> /etc/fstab
$ mount /myshare

Samba config

Add this section in your /etc/samba/smb.conf :

[myshare]
        path = /myshare
        writable = yes
	vfs objects = shadow_copy2
	shadow:snapdir = .snapshots
	shadow:sort = desc

Reload samba

$ /etc/init.d/samba reload

Use

Create snapshot directory and run the script :

$ mkdir -p /myshare/.snapshots
$ /etc/ceph/scripts/autosnap.sh
* Create snapshot for myshare: @GMT-2013.08.09-10.16.10-autosnap
synced, no cache, snapshot created.
* Shadow Copy to mount for rbd/myshare :
GMT-2013.08.09-10.14.44

Verify that the first snapshot is correctly mount :

$ mount | grep myshare
/dev/rbd1 on /myshare type xfs (rw,relatime,attr2,inode64,sunit=8192,swidth=8192,noquota)
/dev/rbd2 on /myshare/.snapshots/@GMT-2013.08.09-10.14.44 type xfs (ro,relatime,nouuid,norecovery,attr2,inode64,sunit=8192,swidth=8192,noquota)

Also, you can add this on crontab to run everyday the script :

$ echo "00 0    * * *   root    /bin/bash /etc/ceph/scripts/autosnap.sh" >> /etc/crontab

More

Ceph Project : http://ceph.com/

Samba Shadow Copy : http://www.samba.org/samba/docs/man/manpages/vfs_shadow_copy2.8.html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.