Saving system proposal

Hi,

I post here an idea for the saving system on Blender.

Actually, we have some options to save our work.

Manually increment our save, the auto save and some addons.

The autosave is in the TEMP file and it replace each new auto save.

I will be great to have a folder in the project file with those auto saved files like this and without replacing the old file by the new file.


I fact it’s like maya and it saved my life a ton of times.

Because right now, with the blender system, I cannot reopen an old file after a crash or if it is replaced by the new auto save.

With my mockup, we will have lot of data, but by experience, it’s usefull and one time we have finish our project we can zip or delete the folder.

We maybe could add an option in the prefs to use this system or the old one for people who prefer stay with the current system.

What do you think ?

+1 @pitiwazou

That would be a very useful option to have. It would certainly have saved me from losing important work countless times.

Hi @pitiwazou,

You know you can make a “symbolic link” from your “temp” to your file folder and have all autosaved near your blend in a specific folder if you want.
Utilise simplement un petit programme sur window qui fait des liens symboliques ou sur Mac ou Linux, tu les écrits en fichier text simplement.
Salut.
Spirou4D

Ouaip mais ce serait mieux que ce soit inclus de base dans blender ^^

Lapineige is making an addon to do this kind of auto save !

http://blenderlounge.fr/forum/viewtopic.php?f=26&t=1037

This is a great idea! I know I save multiple versions whenever I do a massive change. It would be nice to easily do that! +1 from me!

This sounds pretty cool. Reminds me a bit of the Versions features some DAWs are now implementing where you can save versions of your project and go back to them when you need to without having to manually create a whole new file using Save As. Pretty slick stuff.

AFAICS this can be done as an addon,

Simple example of an addon that always incremental saves, could be made a menu item too.

Or it could be kept automatic and have some logic added so it ensures files are at least saved with some time between them (addon preference) This way it wouldn’t be annoying to make quick edits and resave a few seconds after the previous save, and the number of files doesn’t explode.


bl_info = {
    "name": "Incremental Blend Saves",
    "version": (0, 1),
    "blender": (2, 74, 0),
    "location": "Automatically activated on save",
    "description": "Writes versions of the file into 'versionss'",
    "category": "System",
    }


import bpy
from bpy.app.handlers import persistent

SUBDIR = "blend_versions"


@persistent
def on_save(dummy):
    import os

    filepath = bpy.data.filepath
    if not os.path.exists(filepath):
        return

    f_dir, f_file = os.path.split(filepath)

    f_file_base, f_file_ext = os.path.splitext(f_file)
    f_dir_inc = os.path.join(f_dir, SUBDIR)

    os.makedirs(f_dir_inc, exist_ok=True)

    version = 1
    while True:
        filepath_version = os.path.join(
                f_dir_inc,
                "%s_%03d%s" % (f_file_base, version, f_file_ext))
        if not os.path.exists(filepath_version):
            break
        version += 1

    import shutil
    shutil.copyfile(filepath, filepath_version)
    print("Backed up to %r" % filepath_version)


def register():
    bpy.app.handlers.save_pre.append(on_save)


def unregister():
    bpy.app.handlers.save_pre.remove(on_save)


if __name__ == "__main__":
    register()

Can you elaborate on this? - Why can’t you use existing auto-saves after a crash?

Thx for your script, I will try this.

For example, this week, I have a scene, I save the scene. After, I need to apply some modifiers to send my scene to maya and give the scene to my client.
I don’t want to save this scene on blender with the modifiers applied, but After some time, I forgot and save the document.

I cannot use incremental save because it’s only one scene replaced by the new and the new is the scene with modifiers applied.

So with incremental like I posted yesterday, I could open the good scene.

Just go to User Prefs>file and change save versions to the number you want to keep. It will save and increment the numbers of the saved versions as blend1, blend2, blend3 …

Is this not what you are looking for?

Blend1, blend2, blend3 are not auto saved file and they are in the same directory that your current scene, so it’s messy I think.

You might think it’s messy but if you had saved a file accidentally causing problems this will get you a working version of the file.

In my case I was testing a daily build with my current project and saved the file. It turns out that the act of saving the file corrupted all the packed png files for my textures so when I opened the file in the 2.74 none of the images were visible. Funny thing is I checked and they still worked in the daily build.

Luckily I had the save versions enabled and I was able to grab the previous version and just save as to get back to a working file.

No save versions does not correct the auto-save issue and I agree the having the auto-save keep a few copies would be helpful.

Mais alors tu peux changer directement l’emplacement du dossier temp dans les préférences utilisateurs si tu veux pour le mettre à coté de ton blend dans un dossier, non?

Faudrait le faire à chaque fois.

Lapineige is working on it, we will show you the addon after :wink:

The goal of the addon is to do this.


The problem with using a subdirectory like this is that it can muck up linked data if you’re using relative paths. The .blend1, .blend2, etc. files are already incremental saves; great as rudimentary versioning (and you can increase those values in User Preferences). Autosave in /tmp has been very helpful for recovery purposes. For anything more than that, I use actual version control (Mercurial, in my case).

The answer to question I wanted to ask?

You are right, blend 1, 2 is usefull too, I use it too but it works when saving and have an auto incremental save in a directory of the project will be great too.

With the current incremental system (blend1, blend2…)


I’m not sure I understand what you’re asking here. Could you restate in another way?

@pitiwazou, there’s still the issue of linked assets. By itself, a .blend file has no self-awareness to know whether it’s the original file or an auto incremental save… so you’d either have to remap relative links when incrementally saving or you’d have to give the .blend this self-awareness (not too difficult) and remap paths when the file is loaded. And which files should the auto incremental save .blend link to? Should it be the original linked file, or should it link to a corresponding incremental save of the linked file? My assumption is that it would be the original file, but it’s a question worth asking.

Hi everyone,
As pitiwazou said, i’m working on this kind of feature.
I actually made a working add-on, with some basic options. Auto Save Incremental: https://github.com/lapineige/Blender_add-ons/blob/master/AutoSaveIncremental/AutoSaveIncremental_v1-3.py

(this is a WIP, with a lot of bad code stuff, messy code, realy few comments, …)

Also, it is only working on windows for the moment - I do not had time to made it working on linux (and I have no mac to test it).
(Is anyone know a way to convert path automatically… :))

But I’m struggling with the modal doing the timer job:

  1. It do not update on another window than the active one (at script launch) => it can’t be launched from the user prefs.

  2. If the file is saved with another name (for instance: on the image above, when renaming fro Toto_001 to bouba_001), it need to be restarted.
    For now, you need to stop it like that (before saving !):
    http://i.gyazo.com/99ea997fa7169b0081b3c61991e47dde.gif
    Then just restart it.

  3. I have an idea about how to fix it with some handlers stuff, I will do that as soon as possible.
    The issue is that it is a modal, and I want to block it when running another instance of this modal. So I use a property, but it doesn’t update since the new modal (invoke) code is finished - and it delete this blocking value at the end, to be able to do his job.
    As I said, I have a solution, but is there a way to stop a modal operator from outside - with python ?

  4. I wanted to use a handler - a scene update one - to be sure it will always be updated. But it fails, as the handler is lanching the save operator ==> so it update the scene, relaunch itself,… :frowning:
    I wanted to block it thanks t a property, but it is like it do not update it in time / relaunch it so many times, like in a infinite loop.
    Any idea ? :slight_smile:

That is also an issue with the classical incremental tool (that you can use with the ‘+’ on the save screen), if you use it with other files witch refers to it.
For that, I made an add-on, called Save Incremental (I know, it’s a bit confusing): https://github.com/lapineige/Blender_add-ons/blob/master/SaveIncremental_v1-6.py
It save your file, and save a copy with an incremented number (witch can be customized, it just always increment the last number of the file name).
So the main file as always the same name, and your have your incremental save.

About this topic-related feature, it also allows you to always have this auto save in 1 directory on your PC - not always with you file, witch can be annoying.

Good question… it will continue to work if the original path were absolute. If not, it will fail.
I could answer that is just a temporary backcup in case of crash or if you want to come back to an old version.
But maybe I can change the path to the linked librairies…