Discussion:
Using lftp to download backups via FTP, retaining recent backups on host
Mark Rogers
2013-06-06 15:44:40 UTC
Permalink
I have a need to download files via FTP from a host, deleting old backups on
the host but retaining recent ones. In other words, we want to archive all
backups off the host, and only leave the last one or two days of backups on
the host.

I have never used lftp before but it looked like I could so something like this:

- Download (using "mirror -c") all files more than 2 days old
(--older-than=2days), deleting them on success (--remove-source-files)
- Download again but without the --older-than and --remove-source-files
switches to download everything else, without deleting it

This works on day 1, but when it runs the next day it skips the files it
already has and doesn't delete them (even if they're now more than 2 days old).

Is this by design, or a bug? Is there a way to work around this?

I'm using the version in the Ubuntu 12.04 LTS repositories (4.3.3) if that
makes a difference.
--
Mark Rogers // More Solutions Ltd (Peterborough Office) // 0844 251 1450
Registered in England (0456 0902) 21 Drakes Mews, Milton Keynes, MK8 0ER
Alexander V. Lukyanov
2013-07-18 08:14:53 UTC
Permalink
Post by Mark Rogers
This works on day 1, but when it runs the next day it skips the
files it already has and doesn't delete them (even if they're now
more than 2 days old).
Is this by design, or a bug? Is there a way to work around this?
It's by design. --Remove-source-files only removes the files being downloaded.
If a file was not just downloaded, it won't be removed.

I can suggest a workaround - mirror to two different directories,
one for old files (older than 2 days) to remove remotes, and another
for all files. You can even use hard links locally to save disk space.
--
Alexander.
Loading...