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

Add restore hooks feature #213

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rdelaage
Copy link
Contributor

@rdelaage rdelaage commented Jul 12, 2022

Hi!
This PR attempts to add the feature requested in #173
fix #173

You can configure these hooks in a new restore node in the location object, for example:

locations:
  home:
    from:
      - /home/user/Desktop
    to:
      - hdd
    hooks:
      backup:
        before:
          - echo this is before backuping
      restore:
        before:
          - echo this is before restoring
          - echo this is a second message before restoring
        after:
          - echo this is after restoring
        success:
          - echo restore successed
        failure:
          - echo restore failed

The workflow is the same as backup hooks.

@vercel
Copy link

vercel bot commented Jul 12, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
autorestic ✅ Ready (Inspect) Visit Preview Sep 14, 2022 at 11:09AM (UTC)

@cupcakearmy
Copy link
Owner

Thanks for the PR!

I'm not 100% on board with the config file. I think it is a bit messy and confusing if we have 2 sections for hooks. one called hooks and one restore.

Probably something better would be to move the hooks object one layer deeper for backup and restore

locations:
  home:
    from:
      - /home/user/Desktop
    to:
      - hdd
    hooks:
      backup:
        before:
          - echo this is before backuping
      restore:
        after:
          - echo this is after restoring

This would habe breaking changes to the config though.

Thoughts? And sorry for the long wait!

@rdelaage
Copy link
Contributor Author

Yes, I didn't want to introduce a breaking change but it would be definitely better.

I'm ok to introduce this breaking change but how to handle the old config ?

One could simply warn users about the change and those who have not changed the file might encounter problems (this would not be great for a backup tool).
We could also check the version number of the configuration file and warn the user about the change or even migrate the configuration file but this requires the development of a migration feature (another PR)

@rdelaage
Copy link
Contributor Author

I just saw how to handle it in internal/config.go. Since it is a breaking change I will just bump the version of the config file to 3 and write the doc for the website

@rdelaage
Copy link
Contributor Author

@cupcakearmy The configuration file has been changed, I wrote a little piece of docs to explain the new feature and to explain how to migrate the old configuration file. Can you give me feedback ?

@rdelaage
Copy link
Contributor Author

rdelaage commented Oct 7, 2022

Hi @cupcakearmy, any news on this PR ? Is the new config file ok for you ?

@rdelaage
Copy link
Contributor Author

Hey @cupcakearmy I am sorry to ping you again ;). Do you have suggestion to get this PR merged ?

@cupcakearmy
Copy link
Owner

Hey, yes! No worries :)

Thanks for all the work, I know it's frustrating when prs don't get merged. The reason I was waiting is because I'm rewriting the whole logging stuff and touching a lot of files. However I won't be finished anytime soon so I guess we could merge this.
Im not home rn, I'll check later. Make sure that there is good usability and clear instructions when the new version drops and that docs are clear enough

@rdelaage
Copy link
Contributor Author

Before merging this PR I had an idea in this comment in #257 #257 (comment). I think it can help to build snapshot more easily (A location is more of a snapshot/group than actually a location/path) for example when you want to backup a service deployed with docker compose you might want to backup a database dump, a volume containing data and the deployment files in the same snapshot.

@silopolis
Copy link

Please, this is so much needed ! 🙏

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

Successfully merging this pull request may close these issues.

Restore hooks
3 participants