Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Trash and Archives #7

Open
Forever-A-Hermit opened this issue Oct 28, 2021 · 3 comments
Open

Clean up Trash and Archives #7

Forever-A-Hermit opened this issue Oct 28, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@Forever-A-Hermit
Copy link

Would it be possible to clear the trash and archive folders after a specified number of days to keep them from growing indefinitely? I still like having the safety net that the trash and archives provide, so I'd rather not enable the "--noarchive" option.

@elesiuta
Copy link
Owner

I have thought about this before, and would rather not add this feature directly to backupy for a few reasons:

  1. I currently don't have the time to test and maintain this feature with the same level of reliability you can expect from the rest of backupy
  2. From a user design standpoint I am trying to keep it simple and minimise the number of features and options
  3. There are other tools that can achieve this such as maid or you can write your own

Here's a short example for your use case that you can keep in and run from the .backupy folder (I have not tested this)

#!/usr/bin/env python3
from datetime import datetime
from os import listdir, path
from shutil import rmtree
from time import time

def clean(base_path):
    now = datetime.fromtimestamp(time())
    for dir in listdir(base_path):
        if (now - datetime.strptime(dir, "%y%m%d-%H%M")).days > 7:
            rmtree(path.join(base_path, dir))

clean("Archive")
clean("Trash")

@elesiuta elesiuta added the enhancement New feature or request label Oct 29, 2021
@elesiuta
Copy link
Owner

I'll leave this open and may get to it someday, and if I do, I would also add the option to keep the X most recent versions of each file, and keep Y versions per week, month, year, etc.

@Forever-A-Hermit
Copy link
Author

Forever-A-Hermit commented Oct 30, 2021

I respect the preference to not include it for the reasons you've outlined. Thank you for providing this small Python script as a work-around. With a modification or two on my end, this will fit my use case perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants