[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About network failures while uploading



On 03/08/14 07:24, tarsnap wrote:
> On Sat, 8 Mar 2014 14:41:50 +0000
> Colin Percival <cperciva@tarsnap.com> wrote:
>> I'd recommend using the --checkpoint-bytes option with a fairly low
>> setting (e.g., --checkpoint-bytes 32M) so that you'll have lots of
>> checkpoints created.  That way when an archive fails you'll still have
>> the first section of the archive stored -- and that data can then be
>> used for deduplication purposes when you create another archive, which
>> will make future archives use less bandwidth and complete faster.
> 
> Thanks for your reply.
> So I have to do 2 things:
> 1) add the checkpoints option
> 2) create another (NOT the same) archive?

You can try creating an archive with the same name as you used before.  If
it fails, that means the previous archive got created successfully.

>> Of course, finding an internet connection which doesn't break for 5
>> minutes at a time would be ideal.  (5 minutes is how long tarsnap will
>> keep on trying to reconnect.)
> 
> The internet connection breaks down when the power goes out, which
> happens quite frequently: 2 times a day for 2 hours each.
> The laptop runs longer than 5 minutes on its own battery, which means
> tarsnap will always 'give up'.
> 
> Which brings me to the following feature request: 
> A command line option to set the
> 'retry time' (from 5 min. to inf., and frequency--if not automatic as
> function of 'retry time').

The attached patch adds a completely untested and undocumented --retry-forever
option.  Let me know if it works and is useful. :-)

-- 
Colin Percival
Security Officer Emeritus, FreeBSD | The power to serve
Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid
--- lib/netpacket/netpacket_op.c	2014-02-17 01:37:46.000000000 -0800
+++ lib/netpacket/netpacket_op.c	2014-03-08 07:57:53.000000000 -0800
@@ -32,6 +32,9 @@
     0, 0, 1, 2, 4, 8, 15, 30, 60, 90, 90
 };
 
+/* Global tarsnap option declared in tarsnap_opt.h. */
+int tarsnap_opt_retry_forever = 0;
+
 /* Time before which we shouldn't print a "connection lost" warning. */
 static struct timeval next_connlost_warning = { 0, 0};
 
@@ -241,6 +244,8 @@
 
 	/* Have we lost our connection / failed to connect too many times? */
 	NPC->ndrops += 1;
+	if (tarsnap_opt_retry_forever && NPC->ndrops > MAXRECONNECTS)
+		NPC->ndrops = MAXRECONNECTS;
 	if ((NPC->ndrops > MAXRECONNECTS) ||
 	    (NPC->serveralive == 0 && NPC->ndrops > MAXRECONNECTS_AWOL)) {
 		warn0("Too many network failures");
--- tar/bsdtar.c	2014-02-17 01:37:46.000000000 -0800
+++ tar/bsdtar.c	2014-03-08 07:58:45.000000000 -0800
@@ -469,6 +469,9 @@
 		case OPTION_NO_QUIET:
 			optq_push(bsdtar, "no-quiet", NULL);
 			break;
+		case OPTION_NO_RETRY_FOREVER:
+			optq_push(bsdtar, "no-retry-forever", NULL);
+			break;
 		case OPTION_NO_SAME_OWNER: /* GNU tar */
 			bsdtar->extract_flags &= ~ARCHIVE_EXTRACT_OWNER;
 			break;
@@ -531,6 +534,9 @@
 		case OPTION_RECOVER:
 			set_mode(bsdtar, opt, "--recover");
 			break;
+		case OPTION_RETRY_FOREVER:
+			optq_push(bsdtar, "retry-forever", NULL);
+			break;
 		case OPTION_SNAPTIME: /* multitar */
 			optq_push(bsdtar, "snaptime", bsdtar->optarg);
 			break;
@@ -1466,6 +1472,11 @@
 			goto optset;
 
 		bsdtar->option_quiet_set = 1;
+	} else if (strcmp(conf_opt, "no-retry-forever") == 0) {
+		if (bsdtar->option_retry_forever_set)
+			goto optset;
+
+		bsdtar->option_retry_forever_set = 1;
 	} else if (strcmp(conf_opt, "no-snaptime") == 0) {
 		if (bsdtar->option_snaptime_set)
 			goto optset;
@@ -1495,6 +1506,12 @@
 
 		bsdtar->option_quiet = 1;
 		bsdtar->option_quiet_set = 1;
+	} else if (strcmp(conf_opt, "retry-forever") == 0) {
+		if (bsdtar->option_retry_forever_set)
+			goto optset;
+
+		tarsnap_opt_retry_forever = 1;
+		bsdtar->option_retry_forever_set = 1;
 	} else if (strcmp(conf_opt, "snaptime") == 0) {
 		if (bsdtar->mode != 'c')
 			goto badmode;
--- tar/bsdtar.h	2014-02-17 01:37:46.000000000 -0800
+++ tar/bsdtar.h	2014-03-08 07:54:57.000000000 -0800
@@ -105,6 +105,7 @@
 	int		  option_no_config_include_set;
 	int		  option_quiet;
 	int		  option_quiet_set;
+	int		  option_retry_forever_set;
 	int		  option_insane_filesystems;
 	int		  option_insane_filesystems_set;
 	const char	**configfiles;		/* --configfile */
@@ -199,6 +200,7 @@
 	OPTION_NO_NODUMP,
 	OPTION_NO_PRINT_STATS,
 	OPTION_NO_QUIET,
+	OPTION_NO_RETRY_FOREVER,
 	OPTION_NO_SAME_OWNER,
 	OPTION_NO_SAME_PERMISSIONS,
 	OPTION_NO_SNAPTIME,
@@ -214,6 +216,7 @@
 	OPTION_RECOVER,
 	OPTION_RECOVER_DELETE,	/* Operation mode, not a real option */
 	OPTION_RECOVER_WRITE,	/* Operation mode, not a real option */
+	OPTION_RETRY_FOREVER,
 	OPTION_QUIET,
 	OPTION_SNAPTIME,
 	OPTION_STORE_ATIME,
--- tar/cmdline.c	2014-02-17 01:37:46.000000000 -0800
+++ tar/cmdline.c	2014-03-08 07:51:48.000000000 -0800
@@ -130,6 +130,7 @@
 	{ "no-print-stats",	  0, OPTION_NO_PRINT_STATS },
 	{ "no-quiet",		  0, OPTION_NO_QUIET },
 	{ "no-recursion",         0, 'n' },
+	{ "no-retry-forever",	  0, OPTION_NO_RETRY_FOREVER },
 	{ "no-same-owner",	  0, OPTION_NO_SAME_OWNER },
 	{ "no-same-permissions",  0, OPTION_NO_SAME_PERMISSIONS },
 	{ "no-snaptime",	  0, OPTION_NO_SNAPTIME },
@@ -144,6 +145,7 @@
 	{ "quiet",		  0, OPTION_QUIET },
 	{ "read-full-blocks",	  0, 'B' },
 	{ "recover",		  0, OPTION_RECOVER },
+	{ "retry-forever",	  0, OPTION_RETRY_FOREVER },
 	{ "same-owner",	          0, OPTION_SAME_OWNER },
 	{ "same-permissions",     0, 'p' },
 	{ "snaptime",		  1, OPTION_SNAPTIME },
--- tar/tarsnap_opt.h	2014-02-17 01:37:46.000000000 -0800
+++ tar/tarsnap_opt.h	2014-03-08 07:48:30.000000000 -0800
@@ -4,6 +4,9 @@
 /* Use multiple TCP connections when writing an archive. */
 extern int tarsnap_opt_aggressive_networking;
 
+/* Keep trying forever if connection lost. */
+extern int tarsnap_opt_retry_forever;
+
 /* Print statistics using "human-readable" SI prefixes. */
 extern int tarsnap_opt_humanize_numbers;