OpenBagTwo / gsb

A tool for managing incremental backups of your save states using Git!
https://openbagtwo.github.io/gsb/
GNU General Public License v3.0
0 stars 0 forks source link

Backup Deletion #33

Closed OpenBagTwo closed 9 months ago

OpenBagTwo commented 9 months ago

Summary

Implements #8

List of Changes

Tech Debt and Other Concerns

Validation Performed

PR Type

Checklist:

OpenBagTwo commented 9 months ago
$ cd /path/to/my/minecraft/worlds/backup
$ du -h -d0 .
64G .
$ git gc
one eternity later ``` Enumerating objects: 55317, done. Counting objects: 100% (55317/55317), done. Delta compression using up to 24 threads Compressing objects: 100% (22202/22202), done. Writing objects: 100% (55317/55317), done. Total 55317 (delta 37312), reused 48423 (delta 32838), pack-reused 0 Enumerating cruft objects: 1548, done. Traversing cruft objects: 3255, done. Counting objects: 100% (1548/1548), done. Delta compression using up to 24 threads Compressing objects: 100% (1238/1238), done. Writing objects: 100% (1548/1548), done. Total 1548 (delta 710), reused 884 (delta 310), pack-reused 0 ```
$ du -h -d0 .
55GB    .
$ gsb delete <17-untagged-backup-hashes>
Could not delete branch gsb:
    'Branch not found: gsb'
To permanently delete these backups, run the command:
  git gc
$ du -h -d0
55G .
$ git gc
a few moments later ``` Enumerating objects: 55328, done. Counting objects: 100% (55328/55328), done. Delta compression using up to 24 threads Compressing objects: 100% (17739/17739), done. Writing objects: 100% (55328/55328), done. Total 55328 (delta 37312), reused 55307 (delta 37312), pack-reused 0 Enumerating cruft objects: 1558, done. Traversing cruft objects: 3274, done. Counting objects: 100% (1558/1558), done. Delta compression using up to 24 threads Compressing objects: 100% (848/848), done. Writing objects: 100% (1558/1558), done. Total 1558 (delta 711), reused 1557 (delta 710), pack-reused 0 ```
$ du -h -d0 .
55G .

Oh right. Because the original branch wasn't gsb and was thus not deleted (that was the whole "Could not delete branch gsb" thing) , so those old commits aren't actually orphaned.

$ git branch
* gsb
  main
$ git branch -D main
Deleted branch main (was 05a457b2).
$ git gc
a few moments later ``` Enumerating objects: 55328, done. Counting objects: 100% (55328/55328), done. Delta compression using up to 24 threads Compressing objects: 100% (17739/17739), done. Writing objects: 100% (55328/55328), done. Total 55328 (delta 37312), reused 55328 (delta 37312), pack-reused 0 Enumerating cruft objects: 1558, done. Traversing cruft objects: 3274, done. Counting objects: 100% (1558/1558), done. Delta compression using up to 24 threads Compressing objects: 100% (847/847), done. Writing objects: 100% (1558/1558), done. Total 1558 (delta 711), reused 1558 (delta 711), pack-reused 0 ```
$ du -h -d0 .
55G .

:thinking:

one stack exchange later

$ git gc --prune=now
Enumerating objects: 55328, done.
Counting objects: 100% (55328/55328), done.
Delta compression using up to 24 threads
Compressing objects: 100% (17739/17739), done.
Writing objects: 100% (55328/55328), done.
Total 55328 (delta 37312), reused 55328 (delta 37312), pack-reused 0
$ du -h -d0
54G .

After all that back-and-forth that's not hugely impressive, but it is something...

Anyway, clearly the message needs to be updated, because git gc won't delete diddly for two weeks by default.

OpenBagTwo commented 9 months ago

Message now reads:

Deleted backups are now marked as "loose." To delete them immediately, run the command:
  git gc --aggressive --prune=now

(as tested on my small artificial repo)

OpenBagTwo commented 9 months ago

I also tested this on one of my coding git repos:

$ du -h -d0 .
98M     .
$ git prune
$ du -h -d0 .
88M     .
$ git gc --aggressive --prune=now
Enumerating objects: 5391, done.
Counting objects: 100% (5391/5391), done.
Delta compression using up to 24 threads
Compressing objects: 100% (4744/4744), done.
Writing objects: 100% (5391/5391), done.
Total 5391 (delta 3717), reused 819 (delta 0), pack-reused 0
$ du -h -d0 .
62M     .

So this confirms that git gc --prune=now is worth doing over just git prune (because of all that compression and packing, I guess).

I do like that git prune --dry-run enumerates all of the loose objects, though...