Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Tower of Hanoi backup rotation: How to do it without labeled tapes?

$
0
0
I'm having a really tough time trying to figure out how to do the Tower of Hanoi backup rotation scheme if my "tapes" are unlabeled. I'm unwillingly coming to the conclusion that it is impossible to do it without labeling the "tapes".

Consider a backup producer that randomly produces backups. Some backups maybe only hours apart, and some maybe days or weeks apart. The only thing that I know for sure is that newer backups passed to my consumer will always be newer than the previous backup given to me.

As the consumer, I have limited space. I can only hold on to N backups. (For ease of discussion, let's say N == 5 because there is a nice graphic to reference in the wikipedia article.) I want to try to give as far back a backup as possible, but with relatively good coverage for the intermediate backups, hence the Tower of Hanoi scheme. Additionally, my consumer is almost stateless. The only state I can retain is the actual backups that I decide to keep. Hence, my description above of "unlabeled tapes".

So let's say that I start off with no backups. The first 5 backups that I get, I'll definitely keep. When the 6th and later backups arrive, how do I choose which backup to discard?

So far my intuition is pointing towards looking at the timestamp on the "tapes". In real life, the "tapes" are actually .zip files. If I get the timestamp and convert to binary, I can look at the number of trailing zeroes. I can use the number of trailing zeroes as a virtual label. No zeroes is an 'A' tape; 1 zero is a 'B' tape; 2 zeroes is a 'C' tape; etc. It sort of works if I could rely on the producer to send backups to the consumer at regular time intervals, but the random timing completely messes things up.

Is this a hopeless case of going without labels, and that I should just label the "tapes"?

The reason why I'm trying to go with minimal state is because the consumer that I'm trying to implement is to be written as a CMD batch file. Although it has support for parsing and writing files, it is not exactly the best tool. Should I just move up to implementing the consumer as a PowerShell script, and save a "label" into the alternate stream available on NTFS file systems?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>