Andrew Bogott has submitted this change and it was merged.

Change subject: Backup dynamicproxy-api's data.db
......................................................................


Backup dynamicproxy-api's data.db

Change-Id: Ibaaf41885de2028cb72b81e566619645f9d6a5a1
---
A modules/dynamicproxy/files/BackupReadme
A modules/dynamicproxy/files/proxydb-bak.sh
M modules/dynamicproxy/manifests/api.pp
3 files changed, 42 insertions(+), 4 deletions(-)

Approvals:
  Andrew Bogott: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/dynamicproxy/files/BackupReadme 
b/modules/dynamicproxy/files/BackupReadme
new file mode 100644
index 0000000..5d567c4
--- /dev/null
+++ b/modules/dynamicproxy/files/BackupReadme
@@ -0,0 +1,8 @@
+This dir contains backups of the sqlite database used by dynamicproxy-api.
+
+To restore:
+
+$ gunzip proxy-whatever.bak.gz
+$ sqlite3 proxy-whatever.bak < data.db
+
+Then replace /etc/dynamicproxy-api/data.db with the restored file.
diff --git a/modules/dynamicproxy/files/proxydb-bak.sh 
b/modules/dynamicproxy/files/proxydb-bak.sh
new file mode 100644
index 0000000..216a0a2
--- /dev/null
+++ b/modules/dynamicproxy/files/proxydb-bak.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+DATE=$(date '+%Y%m%d')
+
+nice -n 19 sqlite3 /etc/dynamicproxy-api/data.db .dump | nice -n 19 gzip -9 > 
/data/project/backup/proxy-${DATE}.bak.gz
+
diff --git a/modules/dynamicproxy/manifests/api.pp 
b/modules/dynamicproxy/manifests/api.pp
index 02c8d1c..3138306 100644
--- a/modules/dynamicproxy/manifests/api.pp
+++ b/modules/dynamicproxy/manifests/api.pp
@@ -15,10 +15,34 @@
         start   => 'true'
     }
 
-    file { '/etc/dynamicproxy-api':
-        ensure => 'directory',
-        owner => 'www-data',
-        group => 'www-data',
+    file {
+        '/etc/dynamicproxy-api':
+            ensure => 'directory',
+            owner  => 'www-data',
+            group  => 'www-data';
+        '/data/project/backup':
+            ensure => 'directory',
+            owner  => 'root',
+            group  => 'root',
+            mode   => '755';
+        '/data/project/backup/README':
+            source => 'puppet:///modules/dynamicproxy/BackupReadme',
+            require => File['/data/project/backup'];
+        '/usr/local/sbin/proxydb-bak.sh':
+            mode => '555',
+            owner => root,
+            group => root,
+            source => 'puppet:///modules/dynamicproxy/proxydb-bak.sh',
+    }
+
+    cron {
+        'proxydb-bak':
+            ensure  => present,
+            user    => root,
+            hour    => 1,
+            minute  => 0,
+            command => '/usr/local/sbin/proxydb-bak.sh > /dev/null 2>&1',
+            require => File["/data/project/backup"];
     }
 
     # Create initial db file if it doesn't exist, but don't clobber if it does.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibaaf41885de2028cb72b81e566619645f9d6a5a1
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Andrew Bogott <[email protected]>
Gerrit-Reviewer: Andrew Bogott <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to