Rush has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/315595

Change subject: WIP: bdsync backup setup for labstore
......................................................................

WIP: bdsync backup setup for labstore

Change-Id: I67cb9b5579788ae4542f86646d01f502f95733df
---
A modules/labstore/files/block_sync.sh
A modules/labstore/manifests/bdsync.pp
A modules/labstore/manifests/device_backup.pp
3 files changed, 72 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/95/315595/1

diff --git a/modules/labstore/files/block_sync.sh 
b/modules/labstore/files/block_sync.sh
new file mode 100644
index 0000000..207d8f6
--- /dev/null
+++ b/modules/labstore/files/block_sync.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#PV_OPTIONS='-p -t -e -r -a -b'
+PV_OPTIONS='-q'
+
+remotehost=$1
+
+remotedev=$2
+
+localdev=$3
+
+remotenice=10
+
+blocksize=16384
+
+/bin/findmnt --notruncate -P -n -c $localdev
+if [ $? -eq 0 ]
+then
+  echo "Local device is mounted.  Operations may be unsafe."
+  exit 1
+fi
+
+/usr/bin/bdsync --blocksize=$blocksize \
+    --remdata "ssh -i /root/.ssh/id_labstore root@$remotehost 'nice 
-${remotenice} /usr/bin/bdsync --server'" \
+    $localdev \
+    $remotedev | pv $PV_OPTIONS | sudo /usr/bin/bdsync --patch=$localdev
diff --git a/modules/labstore/manifests/bdsync.pp 
b/modules/labstore/manifests/bdsync.pp
new file mode 100644
index 0000000..0adfcc8
--- /dev/null
+++ b/modules/labstore/manifests/bdsync.pp
@@ -0,0 +1,15 @@
+class labstore::bdsync {
+
+    package { 'bdsync':
+        ensure => present,
+        before => File['/usr/local/sbin/block_sync'],
+    }
+
+    file { '/usr/local/sbin/block_sync':
+        source => 'puppet:///modules/labstore/block_sync.sh',
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0655',
+    }
+}
+    
diff --git a/modules/labstore/manifests/device_backup.pp 
b/modules/labstore/manifests/device_backup.pp
new file mode 100644
index 0000000..0e0e8a2
--- /dev/null
+++ b/modules/labstore/manifests/device_backup.pp
@@ -0,0 +1,31 @@
+define labstore::device_backup (
+    $remotehost,
+    $remotedev,
+    $localdev,
+    $remotenice,
+    $weekday,
+    $hour=0,
+) {
+
+    include labstore::bdsync
+    $remote_ip = ip_resolve($remotehost, 4)
+
+    $day = {
+        'sunday'    => 0,
+        'monday'    => 1,
+        'tuesday'   => 2,
+        'wednesday' => 3,
+        'thursday'  => 4,
+        'friday'    => 5,
+        'saturday'  => 6,
+    }
+
+    cron { "bdsync-${remotehost}-${remotedev}":
+        ensure      => 'present',
+        environment => 'MAILTO=labs-adm...@wikimedia.org',
+        user        => 'root',
+        command     => "/usr/local/sbin/block_sync ${remote_ip} ${remotedev} 
${localdev} ${remotenice}" 
+        weekday     => $day[$weekday],
+        hour        => $hour,
+    }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/315595
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I67cb9b5579788ae4542f86646d01f502f95733df
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Rush <r...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to