help-tar
[Top][All Lists]
Advanced

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

Re: [Help-tar] telling tar to take a break


From: Sergey Poznyakoff
Subject: Re: [Help-tar] telling tar to take a break
Date: Mon, 29 Oct 2007 16:14:37 +0200

Lucas B. Cohen <address@hidden> ha escrit:

> I use tar to backup data to a tape drive which tends to overheat.
> 
> According to the documentation, there is no option to tell tar to sleep for
> x amount of time every y gigabytes processed, or every z amount of time.

Try the patch below.  It implements additional parameter for
--checkpoint option.  For example, the following command will sleep for
30 seconds after writing each 100 records of data (which corresponds to 1Mb
with the default blocking factor):

tar -c -f archive --checkpoint=100:30 ...

The value before `:' specifies the checkpoint frequency (in tar
records), the value after it gives the time to sleep in seconds.

The patch is against v.1.19 but should probably apply to 1.18 as well.

Please let me know if it works for you.

Regards,
Sergey

Index: src/buffer.c
===================================================================
RCS file: /cvsroot/tar/tar/src/buffer.c,v
retrieving revision 1.113
diff -p -u -r1.113 buffer.c
--- src/buffer.c        17 Oct 2007 09:11:08 -0000      1.113
+++ src/buffer.c        29 Oct 2007 14:00:55 -0000
@@ -616,8 +616,15 @@ do_checkpoint (bool do_write)
               E.g. in Spanish ``Punto de comprobaci@'on de lectura'',
               *not* ``Leyendo un punto de comprobaci@'on'' */
            WARN ((0, 0, _("Read checkpoint %u"), checkpoint));
+         if (checkpoint_sleep)
+           WARN ((0, 0, ngettext ("Sleeping for %lu second",
+                                  "Sleeping for %lu seconds",
+                                  checkpoint_sleep),
+                  (unsigned long) checkpoint_sleep));
          break;
        }
+      if (checkpoint_sleep)
+       sleep (checkpoint_sleep);
     }
 }  
 
Index: src/common.h
===================================================================
RCS file: /cvsroot/tar/tar/src/common.h,v
retrieving revision 1.101
diff -p -u -r1.101 common.h
--- src/common.h        17 Oct 2007 09:11:23 -0000      1.101
+++ src/common.h        29 Oct 2007 14:00:55 -0000
@@ -131,6 +131,8 @@ GLOBAL bool block_number_option;
 
 GLOBAL unsigned checkpoint_option;
 
+GLOBAL time_t checkpoint_sleep;
+
 enum checkpoint_style
   {
     checkpoint_text,
Index: src/tar.c
===================================================================
RCS file: /cvsroot/tar/tar/src/tar.c,v
retrieving revision 1.172
diff -p -u -r1.172 tar.c
--- src/tar.c   17 Oct 2007 09:11:34 -0000      1.172
+++ src/tar.c   29 Oct 2007 14:00:55 -0000
@@ -1546,8 +1546,18 @@ parse_opt (int key, char *arg, struct ar
            }
          checkpoint_option = strtoul (arg, &p, 0);
          if (*p)
-           FATAL_ERROR ((0, 0,
-                         _("--checkpoint value is not an integer")));
+           {
+             if (*p == ':')
+               {
+                 checkpoint_sleep = strtoul (p + 1, &p, 0);
+                 if (*p)
+                   FATAL_ERROR ((0, 0,
+                            _("checkpoint sleep time is not an integer %s")));
+               }
+             else
+               FATAL_ERROR ((0, 0,
+                             _("--checkpoint value is not an integer")));
+           }
        }
       else
        checkpoint_option = 10;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]