#374 auto backup documents


Is it possible, to add an option such as auto backup for all documents in a project?


  • Benito van der Zander

    Perhaps you can use the scripting functions for that.

    What files do you want to backup where?

  • ebi

    ebi - 2012-12-24

    all files (e.g., all .tex and .bib files ,.... ) that are included in a project.
    the backup can be created alongside the original file.
    the backup can be created for example each 10 min

  • Benito van der Zander

    You can use editor.saveCopy(editor.fileName+".bak"); to make a copy of a file.

    Then use

    function backup(){
      var documents = documentManager.documents;
      for (var i=0;i<documents.length;i++) {
        var editor = documents[i].editorView.editor;
        if (editor.fileName() != "")
      setTimeout(backup, 10*60*1000);

    to make a copy of all open files every 10min

    (It is important to use documentManager.documents, instead of documents, because documents only contains the documents at the start of the script)

    Last edit: Benito van der Zander 2012-12-26
  • ebi

    ebi - 2012-12-26

    but this script, doesn't create backup for .bib files (that are included in your project)!

  • scenox

    scenox - 2012-12-26

    I've deleted the .bak extension in the script to simply autosave the original file, but in combination with the option *svn auto checkin at save', I get every 10 mins the dialogue that the file was changed by another application. Is there a way to avoid this dialogue? (Also, the 'not saved' disc icon is still there after script autosave) (I'm on Mac)

    @ebi: It works for me (the .bib file has to be open in texstudio). if you want to auto-backup the whole project folder without opening in texstudio, I suggest using a backup tool.

    Last edit: scenox 2012-12-26
  • Benito van der Zander

    editor.saveCopy is supposed to create a copy, not modifiy the original file.

    You can just use editor.save() for that.

  • scenox

    scenox - 2012-12-27

    Autosaving works now, but SVN checkin isn't triggered (revision number stays the same). If I save manually, SVN checkin works. Sounds like a bug?

  • Benito van der Zander

    Well, that's kind of supposed to happen. editor.save calls the save
    method from qcodeedit, not from texstudio (which would be app.fileSave,
    but that can only save the current file).

    Perhaps you can call svn manually in the script (system("svn commit ..."))


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks