Code

Added debconf queries and code to automatically migrate from v4.
authorSebastian Harl <sh@tokkee.org>
Sat, 19 May 2012 15:58:11 +0000 (17:58 +0200)
committerSebastian Harl <sh@tokkee.org>
Sat, 19 May 2012 15:58:11 +0000 (17:58 +0200)
This is mostly based on the v3 → v4 migration.

debian/changelog
debian/collectd-core.config
debian/collectd-core.postinst
debian/collectd-core.templates

index ce5191113e9d25412b162152807062bd836d4562..26c5329965323eaf326b0615af12e6b3c2842886 100644 (file)
@@ -36,6 +36,8 @@ collectd (5.1.0-1) unstable; urgency=low
     - Documented the upgrade from version 4 to 5.
   * debian/collectd-core.install:
     - Install migrate-4-5.px.
+  * debian/collectd-core.{config,postinst,templates}:
+    - Added debconf queries and code to automatically migrate from v4.
 
  -- Sebastian Harl <tokkee@debian.org>  Sat, 19 May 2012 15:13:21 +0200
 
index 830f0fdec1842e93a9d901dabb1f03157452a36b..25b171819b55718b4d3e8453d5091c0403773883 100755 (executable)
@@ -25,6 +25,18 @@ case "$1" in
                 db_go || true
             fi
         fi
+
+        db_set collectd/auto-migrate-4-5 false
+
+        if dpkg --compare-versions "$2" lt-nl "5.0.0~"; then
+            if perl -e '1' 2> /dev/null && rrdtool > /dev/null 2>&1; then
+                db_input high collectd/auto-migrate-4-5 || true
+                db_go || true
+            else
+                db_input high collectd/migration-4-5 || true
+                db_go || true
+            fi
+        fi
     ;;
 
     reconfigure)
index 4912af44d583be24082663c3623121809bc4823b..0517d15e8bcba36ffe5bbae52863dfd16021d03f 100755 (executable)
@@ -40,6 +40,15 @@ case "$1" in
             # this is only available on Solaris using libkstat
             rm -f /var/lib/collectd/rrd/$hostname/swap/swap-reserved.rrd
         fi
+
+        db_get collectd/auto-migrate-4-5
+        if [ "$RET" = "true" ]; then
+            tmpdir=`mktemp -dt collectd.XXXXXXXXXX`
+
+            cp -a /var/lib/collectd/ /var/backups/collectd-"$2"
+            /usr/lib/collectd/utils/migrate-4-5.px \
+                -indir /var/lib/collectd/rrd/ | bash
+        fi
     ;;
 
     abort-upgrade|abort-remove|abort-deconfigure)
index e727097847fe875751adbc6785c7e5e810d0ce6f..f8ab94f2e3bf52c5a8558ae2c3cb1eb7688f993d 100644 (file)
@@ -24,6 +24,34 @@ _Description: Automatically try to migrate your RRD files?
  .
  See /usr/share/doc/collectd-core/NEWS.Debian for details.
 
+Template: collectd/migration-4-5
+Type: note
+_Description: Layout of RRD files has changed in version 5.0
+ The layout of some RRD files created by collectd has changed since version
+ 4.x. In order to keep your old data you have to migrate it. This can be done
+ by using /usr/lib/collectd-core/utils/migrate-4-5.px.
+ .
+ This step requires both the perl and the rrdtool packages to be installed,
+ which is currently not the case. You need to perform the migration manually.
+ .
+ See /usr/share/doc/collectd-core/NEWS.Debian and the collectd wiki at
+ <http://collectd.org/wiki/index.php/V4_to_v5_migration_guide> for details.
+
+Template: collectd/auto-migrate-4-5
+Type: boolean
+Default: false
+_Description: Automatically try to migrate your RRD files?
+ The layout of some RRD files created by collectd has changed since version
+ 4.x. In order to keep your old data you have to migrate it. This can be done
+ by using /usr/lib/collectd-core/utils/migrate-4-5.px.
+ .
+ This step can be done automatically. In this case a backup of
+ /var/lib/collectd/ is made in /var/backups/. This script is still
+ experimental, though. Do not expect it to work in all cases.
+ .
+ See /usr/share/doc/collectd-core/NEWS.Debian and the collectd wiki at
+ <http://collectd.org/wiki/index.php/V4_to_v5_migration_guide> for details.
+
 Template: collectd/postrm_purge_data
 Type: boolean
 Default: true