--- /dev/null
+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 B6F59431FBF\r
+ for <notmuch@notmuchmail.org>; Tue, 1 Apr 2014 20:35:50 -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 cWBBwKR9oUPu for <notmuch@notmuchmail.org>;\r
+ Tue, 1 Apr 2014 20:35:46 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu\r
+ [18.7.68.35])\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 05F9C431FBD\r
+ for <notmuch@notmuchmail.org>; Tue, 1 Apr 2014 20:35:45 -0700 (PDT)\r
+X-AuditID: 12074423-f79476d000000c51-1e-533b85901910\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-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id BC.0E.03153.0958B335; Tue, 1 Apr 2014 23:35:44 -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 s323Zil7021060; \r
+ Tue, 1 Apr 2014 23:35:44 -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 s323Zgo1010340\r
+ (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+ Tue, 1 Apr 2014 23:35:43 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1WVBxm-0004d3-BF; Tue, 01 Apr 2014 23:35:42 -0400\r
+Date: Tue, 1 Apr 2014 23:35:42 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: David Bremner <david@tethera.net>\r
+Subject: Re: [Patch v5 5/6] notmuch-new: backup tags before database upgrade\r
+Message-ID: <20140402033542.GC25677@mit.edu>\r
+References: <1396401381-18128-1-git-send-email-david@tethera.net>\r
+ <1396401381-18128-6-git-send-email-david@tethera.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1396401381-18128-6-git-send-email-david@tethera.net>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmpileLIzCtJLcpLzFFi42IR4hTV1p3Qah1ssG2bicWN1m5Gi+s3ZzI7\r
+ MHk8W3WL2WPLoffMAUxRXDYpqTmZZalF+nYJXBl/W++xFRyUrFj5eCVzA+NH4S5GTg4JAROJ\r
+ m8/+M0LYYhIX7q1n62Lk4hASmM0ksX7KBSYIZwOjxIK29+wQzikmieurNkCVLWGUePz8I2sX\r
+ IwcHi4CKxMMJKiCj2AQ0JLbtXw42VkRAVeLqtslsIDazgLTEt9/NTCC2sICPxNl/FxhBWnkF\r
+ dCRW/VYDCQsJVEp83XSAGcTmFRCUODnzCQtEq5bEjX8vmUDKQcYs/8cBEuYUcJLoOzgFbJMo\r
+ 0AFTTm5jm8AoNAtJ9ywk3bMQuhcwMq9ilE3JrdLNTczMKU5N1i1OTszLSy3SNdPLzSzRS00p\r
+ 3cQICmp2F+UdjH8OKh1iFOBgVOLhlbhkFSzEmlhWXJl7iFGSg0lJlJcj2DpYiC8pP6UyI7E4\r
+ I76oNCe1+BCjBAezkgjvd1+gHG9KYmVValE+TEqag0VJnPetNdAkgfTEktTs1NSC1CKYrAwH\r
+ h5IE74sWoEbBotT01Iq0zJwShDQTByfIcB6g4e9BaniLCxJzizPTIfKnGBWlxHlfgiQEQBIZ\r
+ pXlwvbCk84pRHOgVYd5/IFU8wIQF1/0KaDAT0GDudVYgg0sSEVJSDYx7pZfszPbJ4OXXXs5b\r
+ ssEma8l73jlMi/1e6dpGOa6a+vz+Ku3Hv3r/Wb2X+3vEb+932copKx+uvBFaPpv7yK2H0fPf\r
+ Zv7qSD106c0rOYuOy7f+bvkrntqrn26g8t9XekZDmtAR3yI25XyXRS6+WTv2vjBLqkhSD1wt\r
+ r8K8qp/prMmd/IfX01OVWIozEg21mIuKEwGUO3diFQMAAA==\r
+Cc: notmuch@notmuchmail.org\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: Wed, 02 Apr 2014 03:35:50 -0000\r
+\r
+Quoth David Bremner on Apr 01 at 10:16 pm:\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
+> 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..e0431c6 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/backup-%04d-%02d-%02d-%02d:%02d:%02d.gz",\r
+\r
+Maybe "dump" instead of "backup" so it's more obvious that it's a\r
+notmuch dump?\r
+\r
+This would be ISO 8601 compatible if you put a 'T' instead of a '-'\r
+between the date and the time.\r
+\r
+Colons tend to get file names into trouble (some file systems don't\r
+support them, tools like scp think they demarcate host names, etc).\r
+How about compact ISO 8601: dump-%04d%02d%02dT%02d%02d%02d.gz?\r
+\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
+Add "..." to indicate a running process? Even better would be a\r
+progress report, but we can add that to TODO.\r
+\r
+> + }\r
+> +\r
+> + if (notmuch_database_dump (notmuch, backup_name, "",\r
+> + DUMP_FORMAT_BATCH_TAG, TRUE)) {\r
+> + fprintf (stderr, "Backup failed. Aborting upgrade");\r
+\r
+Add a "." at the end for consistency.\r
+\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