Re: [Patch v7 5/6] notmuch-new: backup tags before database upgrade
authorAustin Clements <amdragon@MIT.EDU>
Thu, 10 Apr 2014 13:25:57 +0000 (09:25 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:01:27 +0000 (10:01 -0800)
be/901b76ef2c313df70248b1062171795da64c4c [new file with mode: 0644]

diff --git a/be/901b76ef2c313df70248b1062171795da64c4c b/be/901b76ef2c313df70248b1062171795da64c4c
new file mode 100644 (file)
index 0000000..15f3a81
--- /dev/null
@@ -0,0 +1,159 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 89150431FBD\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Apr 2014 06:26:12 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 8K53OS7Z2aiP for <notmuch@notmuchmail.org>;\r
+       Thu, 10 Apr 2014 06:26:02 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu\r
+       [18.7.68.37])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 09214431FBC\r
+       for <notmuch@notmuchmail.org>; Thu, 10 Apr 2014 06:26:01 -0700 (PDT)\r
+X-AuditID: 12074425-f79906d000000cf9-24-53469be7cfcc\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+       (using TLS with cipher AES256-SHA (256/256 bits))\r
+       (Client did not present a certificate)\r
+       by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 99.44.03321.7EB96435; Thu, 10 Apr 2014 09:25:59 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s3ADPxpa028278; \r
+       Thu, 10 Apr 2014 09:25:59 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s3ADPv6n016250\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+       Thu, 10 Apr 2014 09:25:58 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1WYEzN-0003EK-Eq; Thu, 10 Apr 2014 09:25:57 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: Re: [Patch v7 5/6] notmuch-new: backup tags before database upgrade\r
+In-Reply-To: <1396712636-10640-6-git-send-email-david@tethera.net>\r
+References: <1396712636-10640-1-git-send-email-david@tethera.net>\r
+       <1396712636-10640-6-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.17+167~g3863755 (http://notmuchmail.org) Emacs/23.4.1\r
+       (i486-pc-linux-gnu)\r
+Date: Thu, 10 Apr 2014 09:25:57 -0400\r
+Message-ID: <8738hlxqmy.fsf@awakening.csail.mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFnrEIsWRmVeSWpSXmKPExsUixCmqrft8tluwwcwbNhY3WrsZLa7fnMns\r
+       wOTxbNUtZo8th94zBzBFcdmkpOZklqUW6dslcGUsWriMteCJWMWLJb+YGhg/CnYxcnJICJhI\r
+       LJqwhRHCFpO4cG89WxcjF4eQwGwmiR3XpjNCOBsZJWZPv8kE4Zxmkvi2qRUqs4RR4ty+Kawg\r
+       /WwCGhLb9i8HmyUiYCfRc+E8O4gtLOAj8f79LiYQm1PASeL41DcsILaQQLlE76xGsBpRgXiJ\r
+       1n6IXhYBVYmDb/vYQGxeoPveNi9ih7AFJU7OfALWyyygJXHj30umCYwCs5CkZiFJLWBkWsUo\r
+       m5JbpZubmJlTnJqsW5ycmJeXWqRroZebWaKXmlK6iREUlOwuqjsYJxxSOsQowMGoxMN7YJlr\r
+       sBBrYllxZe4hRkkOJiVRXrVJbsFCfEn5KZUZicUZ8UWlOanFhxglOJiVRHg3TgXK8aYkVlal\r
+       FuXDpKQ5WJTEed9aWwULCaQnlqRmp6YWpBbBZGU4OJQkeNNnATUKFqWmp1akZeaUIKSZODhB\r
+       hvMADV8EUsNbXJCYW5yZDpE/xagoJc5rBpIQAElklObB9cKSxitGcaBXhHmLQKp4gAkHrvsV\r
+       0GAmoMGpdi4gg0sSEVJSDYzueSumyp3ceHV5/7P927IbZ/w/zqdyf6Xfm1m/+lKyjny7qsW3\r
+       RfHfSZesy7zfZ646lyiteie88ICWymtv1osZOxfV//t1vV5swq51SpcvnI6xUlIrKbm+dJPz\r
+       wdp7hz1P7nL5OFFgXn555a6wH6t/uXXNXjq3S2bPq/PMbpPNGNYnt06Sv5zCrMRSnJFoqMVc\r
+       VJwIAL+P8Fj1AgAA\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 10 Apr 2014 13:26:18 -0000\r
+\r
+On Sat, 05 Apr 2014, David Bremner <david@tethera.net> wrote:\r
+> All we do here is calculate the backup filename, and call the existing\r
+> dump routine.\r
+>\r
+> Also take the opportity to add a message about being safe to\r
+\r
+opportunity\r
+\r
+> interrupt.\r
+> ---\r
+>  notmuch-new.c        | 29 ++++++++++++++++++++++++++++-\r
+>  test/T530-upgrade.sh |  4 +++-\r
+>  2 files changed, 31 insertions(+), 2 deletions(-)\r
+>\r
+> diff --git a/notmuch-new.c b/notmuch-new.c\r
+> index 82acf69..d269c7c 100644\r
+> --- a/notmuch-new.c\r
+> +++ b/notmuch-new.c\r
+> @@ -989,8 +989,35 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
+>          return EXIT_FAILURE;\r
+>  \r
+>      if (notmuch_database_needs_upgrade (notmuch)) {\r
+> -        if (add_files_state.verbosity >= VERBOSITY_NORMAL)\r
+> +        time_t now = time (NULL);\r
+> +        struct tm *gm_time = gmtime (&now);\r
+> +\r
+> +        /* since dump files are written atomically, the amount of\r
+> +         * harm from overwriting one within a second seems\r
+> +         * relatively small. */\r
+> +\r
+> +        const char *backup_name =\r
+> +            talloc_asprintf (notmuch, "%s/dump-%04d%02d%02dT%02d%02d%02d.gz",\r
+> +                             dot_notmuch_path,\r
+> +                             gm_time->tm_year + 1900,\r
+> +                             gm_time->tm_mon + 1,\r
+> +                             gm_time->tm_mday,\r
+> +                             gm_time->tm_hour,\r
+> +                             gm_time->tm_min,\r
+> +                             gm_time->tm_sec);\r
+> +\r
+> +        if (add_files_state.verbosity >= VERBOSITY_NORMAL) {\r
+>              printf ("Welcome to a new version of notmuch! Your database will now be upgraded.\n");\r
+> +            printf ("This process is safe to interrupt.\n");\r
+> +            printf ("Backing up tags to %s...\n", backup_name);\r
+> +        }\r
+> +\r
+> +        if (notmuch_database_dump (notmuch, backup_name, "",\r
+> +                                   DUMP_FORMAT_BATCH_TAG, TRUE)) {\r
+> +            fprintf (stderr, "Backup failed. Aborting upgrade.");\r
+> +            return EXIT_FAILURE;\r
+> +        }\r
+> +\r
+>          gettimeofday (&add_files_state.tv_start, NULL);\r
+>          notmuch_database_upgrade (notmuch,\r
+>                                    add_files_state.verbosity >= VERBOSITY_NORMAL ? upgrade_print_progress : NULL,\r
+> diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh\r
+> index 67bbf31..d46e3d1 100755\r
+> --- a/test/T530-upgrade.sh\r
+> +++ b/test/T530-upgrade.sh\r
+> @@ -26,9 +26,11 @@ output=$(notmuch search path:foo)\r
+>  test_expect_equal "$output" ""\r
+>  \r
+>  test_begin_subtest "database upgrade from format version 1"\r
+> -output=$(notmuch new)\r
+> +output=$(notmuch new | sed -e 's/^Backing up tags to .*$/Backing up tags to FILENAME/')\r
+>  test_expect_equal "$output" "\\r
+>  Welcome to a new version of notmuch! Your database will now be upgraded.\r
+> +This process is safe to interrupt.\r
+> +Backing up tags to FILENAME\r
+>  Your notmuch database has now been upgraded to database format version 2.\r
+>  No new mail."\r
+>  \r
+> -- \r
+> 1.9.0\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r