Save only 1 copy of each file with versioning

Shlomi Lanton 56 Reputation points
2022-11-02T13:44:26.173+00:00

Hey all,

I have a bucket with many files that are updated many times during the day. I want to enable versioning but limit it to only 1 version back so that the cost of the bucket will not go up a lot. I tried limit it to delete old version after 1 day but that is not good enough seen I re-writing the file many time in a day.

Any other options?

Thanks

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,833 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 50,111 Reputation points
    2022-11-02T15:32:48.997+00:00

    I don't think you are going to be able to use any built in functionality of storage to get this. That isn't what it is designed for. It is a disaster recovery mechanism in case of mistakes, not really a backup system. If you want this functionality then you'll need to implement it in your code yourself. You could do that by having your app (writing the file) rename any existing file to a .bak first. This would overwrite any old version. Then copy the file over the existing file (if any).

    Of course if you are overwriting the same file many times during a single day I don't know how useful your approach is going to be either. It depends on how often you write to the file but if you write to it every hour, for example, then you would need to detect that you messed up the current file within the hour otherwise you will have already stomped on it again. In general backups are only as useful as the frequency in which you back them up. Perhaps you should consider an alternative approach such as storing each days files in their own directory and then having a process that removes folders that are older than your oldest backup you care about (e.g. 1 day). Of course it depends on what you're doing with those files.

    0 comments No comments