1 No replies PREV NEXT >

Report a bug
Automatic Backups for Sublime Text 2 and ST3 (solution)

chris
 

37 posts
Join date: Apr 2013
 

Automatic Backups for Sublime Text 2 and ST3 (solution)

887 days ago 07-15-2015 04:08 am

(2myself, move this to Workshop...)


Background story.
I was almost happy user with Automatic Backups for Sublime Text 2. This very useful plugin not only saves your nerve but makes your creating/editing session smooth. It works like a charm with ST2 but could not work with ST3.
https://github.com/joelpt/sublimetext-automatic-backups

I cannot say why, but I had to move to Sublime Text 3. I found out that there is no worthy replacement for this plugin. Google was not very helpful too. I am glad that the panic idea to use 2to3 (https://docs.python.org/2/library/2to3.html) was canceled after a while.

I discovered that sublimetext-autobackups plugin is probably what I am looking for.
https://github.com/ionutforyou/sublimetext-autobackups

It does the same job just from the box, but the output format IS NOT the same with Automatic Backups for Sublime Text 2. Here is my dirty patch to fix that out.

1.
Find this file sublimetext-autobackups/autobackups/paths_helper.py and replace this part of the code:

@staticmethod
def timestamp_file(filename):
(filepart, extensionpart) = os.path.splitext(filename)

backup_per_day = PathsHelper.backup_per_day
backup_per_time = PathsHelper.backup_per_time
if (backup_per_day and backup_per_time == 'file'):
now_date = str(datetime.datetime.now())
time = now_date[11:19].replace(':', '')
name = '%s_%s%s' % (filepart, time, extensionpart,)
else:
name = '%s%s' % (filepart, extensionpart,)
return name

with this one:

@staticmethod
def timestamp_file(filename):
(filepart, extensionpart) = os.path.splitext(filename)
now_date = str(datetime.datetime.now())
date = now_date[:10]
time = now_date[11:19].replace(':', '-')
name = '%s-%s-%s%s' % (filepart, date, time, extensionpart,)
return name

2.
And here is a Settings - User:
{
"backup_dir": "d:/.sublime3-bkp/",
"backup_on_open_file": false,
"max_backup_file_size_bytes": 262144,
"delete_old_backups": 0,
}

3.
That's all. You've got the same look of backups under ST3 as Automatic Backups for Sublime Text 2 plugin does.

May be the author of sublimetext-autobackups plugin or someone else will add this patch to his github repository along with related external settings.

Special thanks to Steve Cooper, Joel Thornton, Avtandil Kikabidze.
All mentioned guys are welcome here :)

Login to be able to comment

1 No replies PREV NEXT >