Skip to content

Conversation

@mdhoney
Copy link

@mdhoney mdhoney commented Feb 1, 2022

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 the strptime format, 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.py will be required.

@mdhoney
Copy link
Author

mdhoney commented Feb 1, 2022

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':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rather:

if isinstance(d, Path):

"""
if type(d).__name__ == 'PosixPath':
s = d.name
elif type(d) == str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar here.

"""
if type(d).__name__ == 'PosixPath':
s = d.name
elif type(d) == str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar here.

Comment on lines +56 to +57
# get rid of trailing -??? numbers that BackInTime adds
s = s[:-p].strip()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe reading the docs again gives a better way here. :-)

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.

2 participants