added new datetime_from_dir() function to parse BackInTime folder names#50
Open
mdhoney wants to merge 1 commit intoborgbackup:masterfrom
Open
added new datetime_from_dir() function to parse BackInTime folder names#50mdhoney wants to merge 1 commit intoborgbackup:masterfrom
mdhoney wants to merge 1 commit intoborgbackup:masterfrom
Conversation
Author
|
I didn't realize that committing to my branch after initiating the PR would add these changes too. Hence the force-push in order to reset to previous commit. |
| returns a datetime object if the format could be parsed. | ||
| raises ValueError if not. | ||
| """ | ||
| if type(d).__name__ == 'PosixPath': |
Member
There was a problem hiding this comment.
Maybe rather:
if isinstance(d, Path):
| returns a datetime object if the format could be parsed. | ||
| raises ValueError if not. | ||
| """ | ||
| if type(d).__name__ == 'PosixPath': |
Member
There was a problem hiding this comment.
Maybe rather:
if isinstance(d, Path):
| """ | ||
| if type(d).__name__ == 'PosixPath': | ||
| s = d.name | ||
| elif type(d) == str: |
| """ | ||
| if type(d).__name__ == 'PosixPath': | ||
| s = d.name | ||
| elif type(d) == str: |
Comment on lines
+56
to
+57
| # get rid of trailing -??? numbers that BackInTime adds | ||
| s = s[:-p].strip() |
Member
There was a problem hiding this comment.
if it is always "dash digits" you could also use s.rsplit('-', 1).
Comment on lines
+56
to
+57
| # get rid of trailing -??? numbers that BackInTime adds | ||
| s = s[:-p].strip() |
Member
There was a problem hiding this comment.
if it is always "dash digits" you could also use s.rsplit('-', 1).
Comment on lines
+63
to
+66
| dt = datetime.strptime(s, ts_format) | ||
| # adjust time zone offset to get UTC | ||
| tz = int(time.strftime('%z')[:-2]) | ||
| ut = dt - timedelta(hours=tz) |
Member
There was a problem hiding this comment.
maybe reading the docs again gives a better way here. :-)
Comment on lines
+63
to
+66
| dt = datetime.strptime(s, ts_format) | ||
| # adjust time zone offset to get UTC | ||
| tz = int(time.strftime('%z')[:-2]) | ||
| ut = dt - timedelta(hours=tz) |
Member
There was a problem hiding this comment.
maybe reading the docs again gives a better way here. :-)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Back In Time uses rsync+hardlinks, but (on my machine at least) the timestamps get messed up sometimes, so I needed a more reliable way of getting the original timestamp from the directory name (e.g.
20200428-170001-777). It's mostly just adjusting thestrptimeformat, as well as converting the time to UTC (since the folder times are in local time).To actually use this, a small change in
rsynchl.pywill be required.