ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Automatic Backups

by joelpt ALL

Automatic backups with historical navigation for Sublime Text.

Details

Installs

  • Total 12K
  • Win 8K
  • Mac 3K
  • Linux 2K
Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13
Windows 0 0 1 0 0 0 0 0 2 1 1 1 0 0 0 2 2 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 2 0 0 0 3 0 1 0 2 1 0
Mac 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0
Linux 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 2 1 1 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Automatic Backups for Sublime Text

A Sublime Text 2/3 plugin to automatically save off a backup of your files each time you save.

When you edit text files (scripts, prose, whatever) you often find yourself wishing for an older 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 every file you save and copies it into a backup directory structure, ensuring that you never lose an old version of a file.

Installation

  • Install Package Manager.
  • Use Cmd+Shift+P or Ctrl+Shift+P then Package Control: Install Package.
  • Look for Automatic Backups and install it.

If you prefer to install manually on Sublime Text 3, install git, then:

git clone https://github.com/joelpt/sublimetext-automatic-backups "<Sublime Text Packages folder>/Automatic Backups"

If you're still using Sublime Text 2, a manual install will require switching to the last ST2-compatible commit:

cd "<Sublime Text 2 Packages folder>"
git clone https://github.com/joelpt/sublimetext-automatic-backups "Automatic Backups"
cd "Automatic Backups"
git checkout st2-1.0.0

Basic usage

Once installed, any file you save will be automatically copied into your backups folder (defaults to My Documents\Sublime Text Backups on Windows and ~/.sublime/backups on Linux/OSX).

For example, if you change C:\autoexec.bat on Windows, you'll get a backup saved somewhere like:

C:\Users\yourUserName\My Documents\Sublime Text Backups\C\autoexec-2012-03-22-22-22-46.bat

That end bit is the timestamp, so you can see when the file was edited.

To change where the backups are stored, access the plugin's settings in Preferences->Package Settings->Automatic Backups.

To see if it's 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: /home/stanislav/.sublime/backups/etc/hosts-2012-03-22-22-22-46

Backup history navigation

Automatic Backups supports easy navigation through the backup history for any file with stored backups. To use this feature:

  • Press Ctrl+Alt+[ to navigate backwards one step through a file's backup history.
  • Press Ctrl+Alt+] to navigate forwards one step.
  • Press Ctrl+Shift+Alt+[ to jump to the first copy in the history.
  • Press Ctrl+Shift+Alt+] to jump to the current version (that is, the actual file, not a backup).

These commands can also be accessed via Ctrl+Shift+P or Cmd+Shift+P.

Merge from backup history

When viewing a backup file via backup history navigation, press Ctrl+Alt+Shift+M to merge the backup version you're currently viewing with the latest version of the file using an external merge tool of your choosing.

You'll need to specify the command line for this merge tool; for more information go to Preferences->Package Settings->Automatic Backups->Settings - Default.

This command can also be accessed via Ctrl+Shift+P or Cmd+Shift+P.

Backup size considerations

Though this plugin currently has no facility for pruning old backups, this probably won't be a problem for you. I have been running some form of this plugin for 6 years, and have a total of 85000 individual backup files stored totalling 1.25 GB uncompressed. And I can go back to the very first version of any file I've edited in Sublime Text.

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

Credits

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

Created by Joel Thornton.

Originally authored for Sublime Text 1 by Steve Cooper.