GithubHelp home page GithubHelp logo

akalongman / sublimetext-autobackups Goto Github PK

View Code? Open in Web Editor NEW
71.0 5.0 22.0 72 KB

Sublime Text 2/3 Auto backups plugin

License: MIT License

Python 100.00%
sublime-text backup autobackup utility package

sublimetext-autobackups's Introduction

sublimetext-autobackups

Sublime Text 2/3 Auto backups plugin

AutoBackups is a Sublime Text 2/3 plugin, which automatically save a backup copy every time you save or open (if backup file not exists) a file. (Like DreamWeaver.. No, better than DreamWeaver)

When you edit text files (scripts, prose, whatever) you often find yourself wishing for an last version. Ever accidentally deleted a chunk from an important configuration file, or wished you could roll back a document a few hours? This plugin takes a copy of file you open/save and copies it into a backup directory structure, ensuring that you never lose an old version of a file. If enabled setting backup_per_day backups will be saved for each day. If enabled setting backup_per_time backups will be saved for each save.

Sponsors

No sponsors yet.. :(

If you like the software, don't forget to donate to further development of it!

PayPal donate button

Configuration

To change plugin configuration, access the plugin's settings in Preferences->Package Settings->AutoBackups.

Configuration options:

{
  // Don't make changes to this file directly as they can get wiped out when the
  // plugin is updated. Instead transfer what you need to the 'Settings - User' file.

  // The directory where we'll keep our backups. If empty, we'll try to put them in
  // D:/Sublime Text Backups
  "backup_dir": "D:/Sublime Text Backups",

  // If true, also save a backup copy any time a file is opened (if backup file not exists)
  "backup_on_open_file": true,

  // If true, backups saved per day, in separate folders, for example D:/Sublime Text Backups/2013-05-23/myfile.php
  "backup_per_day": true,

  // If set, backups saved per second. possible values: false, "folder" or "file"
  // false - disabled backup per second
  // "folder" - backup example D:/Sublime Text Backups/2013-05-23/095034/myfile.php
  // "file" - backup example D:/Sublime Text Backups/2013-05-23/myfile_095034.php
  // to use this feature, you must have enabled backup_per_day setting
  "backup_per_time": "file",

  // Files larger than this many bytes won't be backed up.
  "max_backup_file_size_bytes": 262144, // = 256 KB

  // Files older than X days will be deleted. If 0 - auto delete disabled
  "delete_old_backups": 0, // days to delete

  // ignore files/folders which match regexes
  "ignore_regexes": [
    // VCS folders
    "/\\.svn/", "/\\.hg/", "/\\.git/", "/\\.bzr/"
    // binary extensions
    ,"\\.(jpg|JPG|jpeg|JPEG|pjpeg|PJPEG|gif|GIF|png|PNG|apng|APNG|bmp|BMP|mp3|MP3|mid|MID|wav|WAV|au|AU|mp4|MP4|3gp|3GP|avi|AVI|wmv|WMV|mpeg|MPEG|mpg|MPG|mkv|MKV|swf|SWF|flv|FLV|zip|ZIP|rar|RAR|tar|TAR|tgz|TGZ|gz|GZ|bz2?|BZ2?|pdf|PDF|docx?|DOCX?|xlsx?|XLSX?|pptx?|PPTX?|rtf|RTF|psd|PSD|cdr|CDR|fla|FLA|exe|EXE)$"
  ],

  // If true, backup file opened in same line as cursor in original file
  "open_in_same_line": true,

  // If true, show backup previews (only in ST3)
  "show_previews": true
}

Installation

With the Package Control plugin: The easiest way to install AutoBackups is through Package Control, which can be found at this site: https://sublime.wbond.net/installation

Once you install Package Control, restart Sublime Text and bring up the Command Palette (Command+Shift+P on OS X, Control+Shift+P on Linux/Windows). Select "Package Control: Install Package", wait while Package Control fetches the latest package list, then select AutoBackups when the list appears. The advantage of using this method is that Package Control will automatically keep AutoBackups up to date with the latest version.

Without Git: Download the latest source from GitHub and copy the AutoBackups folder to your Sublime Text "Packages" directory.

With Git: Clone the repository in your Sublime Text "Packages" directory:

git clone https://github.com/akalongman/sublimetext-autobackups.git AutoBackups

The "Packages" directory is located at:

  • OS X:
    • ST2 ~/Library/Application Support/Sublime Text 2/Packages/
    • ST3 ~/Library/Application Support/Sublime Text 3/Packages/
  • Linux:
    • ST2 ~/.config/sublime-text-2/Packages/
    • ST3 ~/.config/sublime-text-3/Packages/
  • Windows:
    • ST2 %APPDATA%/Sublime Text 2/Packages/
    • ST3 %APPDATA%/Sublime Text 3/Packages/

To see if plugin working, open the console with the View->Show Console menu item. When you save a file, you should see a line like this, indicating that the file has been backed up:

Backup saved to: D:/Sublime Text Backups/2013-05-23/myfile_095034.php

Backup size considerations

To prevent your backup folder from growing too large, check out the max_backup_file_size_bytes and delete_old_backups setting in Preferences->Package Settings->AutoBackups.

Keybindings

To open current file backup, use cmd+alt+b keybinding, or in quick panel type AutoBackup: Open file backup

Contributing

Anyone and everyone is welcome to contribute. Please take a moment to review the CONTRIBUTING.md guidelines for information.

Credits

Credit list in CREDITS

This code is available on Github. Pull requests are welcome.

Created by Avtandil Kikabidze.

License

MIT License

sublimetext-autobackups's People

Contributors

abelarm avatar akalongman avatar martinskou avatar mateatslc avatar thecotne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sublimetext-autobackups's Issues

Recover entire folder

Hey, I recently accidentally deleted a project folder of mine of which I had no backup (only partial file backups created by your plugin). I figured I could write a script that attempts to use all these partial backups to restore the latest version of the project I had on my disk. This was the result. I thought maybe you or someone else would find it useful. I can't guarantee that it will work for every project or system, but it did for mine.

The first argument passed to the script should be the path to the backup folder used by the plugin, and the second argument the path of the project that you want to recover.

enhancement per_day:false per_time:file

I want to be able to set
"backup_per_time": "file"
"backup_per_day": false,

and have files save in proper heirachies, with stamped filenames, like this plugin used to do in ST2
https://github.com/joelpt/sublimetext-automatic-backups

backups/path/to/file/filename.date.ext
backups/path/to/file/filename-date.ext
etc.

Would this be implementable or problematic for the in app previewer ?

I much prefer having all files where they belong, and not in separate dated folders, despite the obvious limit issues.

Backup cleanup?

This is a great plugin!

I am wondering if there is a way to cleanup the backups either automatically, say every week or month, or allow users to invoke a cleanup routine? The backups seem to grow pretty fast especially for people like me who hit save compulsively all the time....

It is unlikely that I'll need backups that are 30 days old and there are many backups in between. Also, maybe one copy per day would be enough for those that are more than a week old. A setting file allowing user to config these would be really nice.

It's a lot to ask I know, but I really hope it'll be perfect for daily usage~~ And I am more than willing to help if you plan to integrate it.

add index for quick-list

actively use your plug-in and a couple of months had accumulated a lot of backups
and now when I open my file copies sublime text 3114 hangs for a minute or two
whether it is possible to implement some kind of indexing and quick filter to quickly open a list of copies of the current file?

ST3 backup files non sorting by date.

When I open backup list for a file, items looking like random sort. If it can be in a date sort and inside of date can be time sort it would be better.

Problem loading autobackups in Sublime Text 3 (Win 7 x64)

Autobackups works fine with ST2, however with ST3, when I copy the plugin to AppData\Roaming\Sublime Text 3\Packages, I got an error:

reloading plugin sublimetext-autobackups.AutoBackups Traceback (most recent call last): File "C:\Users\me\AppData\Roaming\Sublime Text 3\Packages\sublimetext-autobackups\AutoBackups.py", line 28, in <module> from AutoBackups.autobackups import reloader ImportError: No module named 'AutoBackups'
...
File "C:\Users\me\AppData\Roaming\Sublime Text 3\Packages\sublimetext-autobackups\AutoBackups.py", line 32, in <module> import autobackups.reloader ImportError: No module named 'autobackups'

P.S. I've Python 2.7 installed on my machine (wondering if there's a Python 3.x dependency?)

AutoBackups: Open file backup, doesn't work

When I go to the Command Palette and choose AutoBackups: Open file backup it shows an alert box saying "Backups for this file not exists!" but if I go to the backup directory I can see multiple backups of the same file stored.

This are my configurations:

{
    // Don't make changes to this file directly as they can get wiped out when the
    // plugin is updated. Instead transfer what you need to the 'Settings - User' file.

    // The directory where we'll keep our backups. If empty, we'll try to put them in
    // D:/Sublime Text Backups
    "backup_dir": "/Users/OC/sublime_backups/",

    // If true, also save a backup copy any time a file is opened (if backup file not exists)
    "backup_on_open_file": false,

    // If true, backups saved per day, in separate folders, for example D:/Sublime Text Backups/2013-05-23/myfile.php
    "backup_per_day": true,

    // If set, backups saved per second. possible values: false, "folder" or "file"
    // false - disabled backup per second
    // "folder" - backup example D:/Sublime Text Backups/2013-05-23/095034/myfile.php
    // "file" - backup example D:/Sublime Text Backups/2013-05-23/myfile_095034.php
    // to use this feature, you must have enabled backup_per_day setting
    "backup_per_time": "folder",

    // Files larger than this many bytes won't be backed up.
    "max_backup_file_size_bytes": 262144, // = 256 KB

    // Files older than X days will be deleted. If 0 - auto delete disabled
    "delete_old_backups": 20, // days to delete

    // If true, backup file opened in same line as cursor in original file
    "open_in_same_line": true,

    // If true, show backup previews
    "show_previews": true
}

Relative path to sublime_text.exe folder ?

I was hoping to see if there was a way to set the backup folder relative to ST's folder.

My backup folder is _Backups Sublime Text.

My folder structure is like so:

[.]                     [..]                    [Backups Sublime]       changelog.txt           crash_reporter.exe
[Data]                  msvcr100.dll            [Packages]              plugin_host.exe         [Project Folder]
python3.3.zip           python33.dll            subl.exe                sublime.py              sublime_plugin.py
sublime_text.exe        update_installer.exe    [_Backups Sublime Text] [_Send to 3ds Max]
              11 File(s)     27,999,524 bytes
               8 Dir(s)  846,603,526,144 bytes free

Backups not working: TypeError: unorderable types: int() > NoneType()

Just installed via git clone in ST3 3047:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 263, in on_post_save_async
    callback.on_post_save_async(v)
  File "/Users/mitch/Library/Application Support/Sublime Text 3/Packages/AutoBackups/AutoBackups.py", line 56, in on_post_save_async
    self.save_backup(view, 0)
  File "/Users/mitch/Library/Application Support/Sublime Text 3/Packages/AutoBackups/AutoBackups.py", line 66, in save_backup
    if view.size() > settings.get('max_backup_file_size_bytes'):
TypeError: unorderable types: int() > NoneType()

Optionally flag or checkpoint an autobackup file with a suffix

This is a feature request:

Is it possible to add a keyboard shortcut that would flag the autobackups file name with a suffix (a tiny comment) when saving the file. Over the course of a day, I end up with a couple dozen timestamped backups. Sometimes while editing, I immediately want to take a peek at a file I saved 20 minutes or 2 hours ago. If I had saved it with a flag/suffix, I can easily identify that.

The flag could be fixed e.g. _checkpoint or a user prompted string. The resulting autobackups directory would look like this :

mycode_09063.py
mycode_09073.py
mycode_11054.py
mycode_11172_removed_big_feature.py        <- checkpoint / tag
mycode_12031.py
mycode_14300.py
mycode_15712_added_cool_stuff.py           <- checkpoint / tag
mycode_16003.py

Option to save backups next to the original files

Instead of saving all backups in the same location (defaults to ~/sublime_backups), I would prefer for each of the backups to be saved next to the related (original) file.

For example, if I'm working on /path/to/file.md, there would be /path/to/file.md~ as its latest backup.

This is how some Linux text editors have been handling the automatic backup of files.

The file should be backed up before it was saved

What is the point of having 2 identical copies of the same file - at original location and backup directory?

I mean, for a true auto backup the current file at original location should be copied to the backup directory BEFORE it's being written with new data. Current implementation doesn't make sense, when file saved, the original data is lost.

Platform Independent Path to Sublime Folder

Is there a platform-independent way to save the backup files into our Sublime User directory, for example on OSX:

~/Library/Application Support/Sublime Text 3/Packages/User/AutoBackups

I can hardcode the path and the tilda expansion works correctly, but it's not portable to windows & linux.

[wish] delete_old_backups

add "leave_one_backup_for_delete_old_backups"

  • true (not delete the most recent backup)
  • false (default)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.