Mondane / timebackup

A backup like OS X timemachine for Linux/Cygwin
8 stars 3 forks source link

Fix folder deletion logic #1

Closed rossica closed 9 years ago

rossica commented 10 years ago

With delete0 set to 0, the script deletes all hourly backups before they are rotated to the daily folder. Repros 100% when run in cygwin.

Mondane commented 10 years ago

It sounds plausible, but when I browse my backups, it looks ok:

SpaceStation> cd daily/
SpaceStation> ll
drwxr-xr-x    9 Ernst    users         4096 Oct  6 20:11 .
drwxr-xr-x    7 Ernst    users         4096 Oct  7 18:10 ..
drwxr-xr-x   10 Ernst    users         4096 Sep 29 20:11 2014-09-29_20h10m01s
drwxr-xr-x   10 Ernst    users         4096 Sep 30 20:11 2014-09-30_20h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  1 20:11 2014-10-01_20h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  2 20:11 2014-10-02_20h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  3 19:11 2014-10-03_19h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  4 20:11 2014-10-04_20h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  5 20:11 2014-10-05_20h10m01s
SpaceStation> cd ..
SpaceStation> cd hourly/
SpaceStation> ll
drwxr-xr-x   15 Ernst    users         4096 Oct  7 18:10 .
drwxr-xr-x    7 Ernst    users         4096 Oct  7 18:10 ..
drwxr-xr-x   10 Ernst    users         4096 Oct  6 18:11 2014-10-06_18h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  6 19:11 2014-10-06_19h10m02s
drwxr-xr-x   10 Ernst    users         4096 Oct  6 20:11 2014-10-06_20h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  6 21:11 2014-10-06_21h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  7 10:10 2014-10-07_10h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  7 11:11 2014-10-07_11h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  7 12:11 2014-10-07_12h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  7 13:11 2014-10-07_13h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  7 14:10 2014-10-07_14h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  7 15:11 2014-10-07_15h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  7 16:11 2014-10-07_16h10m02s
drwxr-xr-x   10 Ernst    users         4096 Oct  7 17:11 2014-10-07_17h10m01s
drwxr-xr-x   10 Ernst    users         4096 Oct  7 18:10 2014-10-07_18h10m01s

Am I missing something?

One other thing, if delete0 should be increased by one, I think it makes sence to increase all other delete variables too by one.

What do you think?

PS This is the backup folder for another machine:

SpaceStation> ll hourly/
drwxr-xr-x   15 Susan    users         4096 Oct  7 19:21 .
drwxr-xr-x    7 Susan    users         4096 Oct  7 19:21 ..
drwxr-xr-x    9 Susan    users         4096 Oct  6 19:21 2014-10-06_19h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  6 20:21 2014-10-06_20h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  6 21:21 2014-10-06_21h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  7 09:21 2014-10-07_09h20m02s
drwxr-xr-x    9 Susan    users         4096 Oct  7 10:21 2014-10-07_10h20m02s
drwxr-xr-x    9 Susan    users         4096 Oct  7 11:22 2014-10-07_11h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  7 12:21 2014-10-07_12h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  7 13:21 2014-10-07_13h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  7 14:21 2014-10-07_14h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  7 15:22 2014-10-07_15h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  7 17:25 2014-10-07_17h20m02s
drwxr-xr-x    9 Susan    users         4096 Oct  7 18:20 2014-10-07_18h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  7 19:21 2014-10-07_19h20m01s
SpaceStation> ll daily/
drwxr-xr-x    9 Susan    users         4096 Oct  7 13:21 .
drwxr-xr-x    7 Susan    users         4096 Oct  7 19:21 ..
drwxr-xr-x    9 Susan    users         4096 Sep 30 10:22 2014-09-30_10h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  1 13:22 2014-10-01_13h20m02s
drwxr-xr-x    9 Susan    users         4096 Oct  2 13:22 2014-10-02_13h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  3 13:21 2014-10-03_13h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  4 13:20 2014-10-04_13h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  5 13:21 2014-10-05_13h20m01s
drwxr-xr-x    9 Susan    users         4096 Oct  6 12:24 2014-10-06_12h20m02s
SpaceStation> ll weekly/
drwxr-xr-x    5 Susan    users         4096 Oct  7 19:21 .
drwxr-xr-x    7 Susan    users         4096 Oct  7 19:21 ..
drwxr-xr-x    9 Susan    users         4096 Sep 13 20:21 2014-09-13_20h20m02s
drwxr-xr-x    9 Susan    users         4096 Sep 19 20:23 2014-09-19_20h20m01s
drwxr-xr-x    9 Susan    users         4096 Sep 26 13:21 2014-09-26_13h20m02s
SpaceStation> ll monthly/
drwxr-xr-x   12 Susan    users         4096 Oct  3 21:21 .
drwxr-xr-x    7 Susan    users         4096 Oct  7 19:21 ..
drwxr-xr-x    8 Susan    users         4096 Nov  2  2013 2013-11-02_15h20m02s
drwxr-xr-x    9 Susan    users         4096 Nov  9  2013 2013-11-09_17h20m11s
drwxr-xr-x    9 Susan    users         4096 Jan 17  2014 2014-01-17_12h20m03s
drwxr-xr-x    9 Susan    users         4096 Feb 16  2014 2014-02-16_18h20m01s
drwxr-xr-x    9 Susan    users         4096 Mar 19  2014 2014-03-19_18h20m01s
drwxr-xr-x    9 Susan    users         4096 Apr 21 12:28 2014-04-21_12h20m02s
drwxr-xr-x    9 Susan    users         4096 May 21 21:21 2014-05-21_21h20m01s
drwxr-xr-x    9 Susan    users         4096 Jun 23 08:21 2014-06-23_08h20m01s
drwxr-xr-x    9 Susan    users         4096 Jul 24 09:22 2014-07-24_09h20m01s
drwxr-xr-x    9 Susan    users         4096 Aug 24 18:21 2014-08-24_18h20m05s
SpaceStation> ll yearly/
drwxr-xr-x    3 Susan    users         4096 Apr 26  2013 .
drwxr-xr-x    7 Susan    users         4096 Oct  7 19:21 ..
drwxr-xr-x    7 Susan    users         4096 Feb 24  2013 2013-02-24_15h33m03s

That also looks ok to me.

rossica commented 9 years ago

When I look at the manual page for the find command for FreeBSD (which is the OS running my backup server), it confirms what I've been seeing.

https://www.freebsd.org/cgi/man.cgi?query=find&sourceid=opensearch

If you look at the documentation for the -mtime test, it will round up any fractional part of the time difference to the nearest 24-hour period. Due to rounding, any modification time will be greater than 0 * 24 hrs., so it will be pass the test.

Looks like there's a difference between the way find -mtime works between Linux and BSD.

I'm not certain how to fix this other than what I've changed, but it will be off by a day on linux. It's possible to special case the code depending on the target OS, but I think that's messy. Do you have any ideas?

Increasing the other values by 1 is not necessary due to the rounding behavior.

On 10/7/2014 11:02 AM, Mondane wrote:

It sounds plausible, but when I browse my backups, it looks ok:

SpaceStation> cd daily/ SpaceStation> ll drwxr-xr-x 9 Ernst users 4096 Oct 6 20:11 . drwxr-xr-x 7 Ernst users 4096 Oct 7 18:10 .. drwxr-xr-x 10 Ernst users 4096 Sep 29 20:11 2014-09-29_20h10m01s drwxr-xr-x 10 Ernst users 4096 Sep 30 20:11 2014-09-30_20h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 1 20:11 2014-10-01_20h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 2 20:11 2014-10-02_20h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 3 19:11 2014-10-03_19h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 4 20:11 2014-10-04_20h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 5 20:11 2014-10-05_20h10m01s SpaceStation> cd .. SpaceStation> cd hourly/ SpaceStation> ll drwxr-xr-x 15 Ernst users 4096 Oct 7 18:10 . drwxr-xr-x 7 Ernst users 4096 Oct 7 18:10 .. drwxr-xr-x 10 Ernst users 4096 Oct 6 18:11 2014-10-06_18h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 6 19:11 2014-10-06_19h10m02s drwxr-xr-x 10 Ernst users 4096 Oct 6 20:11 2014-10-06_20h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 6 21:11 2014-10-06_21h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 7 10:10 2014-10-07_10h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 7 11:11 2014-10-07_11h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 7 12:11 2014-10-07_12h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 7 13:11 2014-10-07_13h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 7 14:10 2014-10-07_14h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 7 15:11 2014-10-07_15h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 7 16:11 2014-10-07_16h10m02s drwxr-xr-x 10 Ernst users 4096 Oct 7 17:11 2014-10-07_17h10m01s drwxr-xr-x 10 Ernst users 4096 Oct 7 18:10 2014-10-07_18h10m01s

Am I missing something?

One other thing, if delete0 should be increased by one, I think it makes sence to increase all other delete variables too by one.

What do you think?

— Reply to this email directly or view it on GitHub https://github.com/Mondane/timebackup/pull/1#issuecomment-58230187.