All new work lost...

Had to join just for this blurb... I have been editing sketches over weeks at a time on my laptop, comfortable in the fact all my work was saved when I compile (being kind of the standard thing upon compiling ... saving your work for you). So today after achieving a breakthrough with my coding on accelerometers and gyros, I rested comfortably overnight, through the day, knowing I was saved... or so I thought. I have been just closing (hibernating) my laptop with the 5 sketches I was working with still open. Yes... perhaps pretty poor judgment, but it has worked for me for years... But, today... I was confronted with an update available upon opening from my desktop the icon for Arduino to start a NEW sketch, and I said sure... I'll update... I installed the new update (1.05), and when completed... I opened it. To my surprise... It opened all my previously hibernating sketches and opened them in a new 1.05 environment... I thought... How cool... So... I happily closed all my old sketches one at a time until I was left with the new, improved ones... All the work from the previous week was totally gone... they appeared in the same shape as I opened them weeks ago! I cannot find remnants of them anywhere... they were just gone...

At the time of this writing, I saw another link about work lost... and someone suggested I scan for .c or .cpp files of the same name as the sketches... and I see now some files in the user temp directory (\AppData\Local\Temp\build6844841335297355845.tmp) that look promising... (just showed up after a long search... by the way... don't use the search feature... go to the command line prompt and look for "sketch name*" mine showed up as .cpp files... I haven't looked at them yet... but more on the subject if I become learned Master...

Any thoughts as to why this can, could or should happen??? Thanks, Tim

The IDE is not one of the more modern (and somewhat annoying) "I'll save your work for you whether you want it saved or not" designs. It saves your sketches when you tell it to.

Since the sketches are copied to a temporary directory for compiling you hopefully can find some of them at least, before those directories get cleaned up.

Aw man, that sucks! :(

Personally, I use PsPad when in Windows and Geany when in Linux. And I always always Ctrl+S when I pause for any moment.

I think this has happened to all of us ... thankfully, you will be able to re-create that good code! Trust me, I know.


Thank you for the comments, Nick... I have found one out of five that were in question... Other files relating to the other four projects were found, but thankfully the one I REALLY wanted was in both of two temp directories AppData and Local Settings... SO!... I learned something (I hope) Now I realize that I have lost work before but had chalked it up to presumed sloppy editing fingers and cut and paste oopy doos. SAVE, SAVE, SAVE... Tim

Backup your code to a memory stick, 2nd drive or and a fileserver .

simple win7 backup script based upon robocopy, works like a charm, and is free copy it in your arduino code dir, and you just start it manually or let your PC start it timebased



REM arguments
REM /XD bin obj    ... to skip dirs
REM /XO newer
REM /FFT            needed when copying between NTFS and FAT or linux
REM /DCOPY:T        timestamp dirs
REM /MAXAGE:n       skip files older than n days (speed up)


start robocopy "." "F:\BACKUP\Arduino" /E /XO /FFT /DCOPY:T
start robocopy "." "G:\BACKUP\Arduino" /E /XO /FFT /DCOPY:T
start robocopy "." "S:\BACKUP\Arduino" /E /XO /FFT /DCOPY:T

ECHO %date% %time% >> latestbackup.txt 

Personally I also use git to control any major projects. By “major” I mean anything I don’t want to lose, compared to a small example I knock up for the forum.

Install git, then using the command line (console) navigate to the appropriate directory.

git init        # <--- do this once
git add *.ino   # <--- also add .cpp and .h files as appropriate
git commit -m "Initial commit"

Then after making major changes commit what preceded:

git commit -am "Improvements"  # <--- "add" changes, commit them with message

Now if you ever go “duh!” because a change made things work less well you can revert back to a previous version. Plus you effectively have a “backup” in the .git subdirectory.

And you can find what changes you just made:

git diff

FYI - I link to a couple of great Git resources on my answer here. The graphic specifically helped me wrap my head around Git.

:slight_smile: -ChrisK