1

I wrote code to a latex file for several hours without compiling nor manually saving, went for a break, my computer ran out of battery; once it was working again all progress had been lost. I want to avoid this in the future.

I have set my latex editor (texmaker) to regularly autosave, but I also want version control and remote backups, so I have the following script to automatically commit and push:

#!/bin/bash
if ps -ef | grep "texmaker report.tex" ; then
    git commit -a -m "auto-commit progress on report"
    git push origin master
    exit 0
else
    exit 0
fi

As you can see it will only commit if my specific treasured .tex document is being edited, rather than whenever a change has occured in the local repo.

To run this script automatically, I've got the following crontab set up:

0,10,20,30,40,50 * * * * ./autocommit.sh >/dev/null 2>&1

So far it's been working as planned, but it seems this approach might make some of you scream as I'll get meaningless commits. I'm willing to pay that price to avoid the incident, but is there another way to get regular backups with version control that avoids meaningless commits?

Alexandre Holden Daly
  • 6,944
  • 5
  • 25
  • 36
  • I guess this wouldn't have happened if I'd been coding in another language i.e. on my regular IDE, since it autosaves as soon as a change is made, so this problem is perhaps specific to latex. therefore, this post might belong on tex.stackexchange, but I reckon here is good because the debate is about which programming-related tools to solve a problem, not which latex code to use. – Alexandre Holden Daly Jun 23 '14 at 10:41
  • The story of how I lost my progress on this latex document might not be correctly recounted, I'm not 100% sure how or why it happened. – Alexandre Holden Daly Jun 23 '14 at 10:41
  • "wrote code to a latex file" ... "without manually saving". Does not compute. Writing to a file is saving. If the file was lost when the battery died, the file must have been in RAM. Save to an actual disk or a flash storage device next time. – Kaz Dec 21 '14 at 15:45

0 Answers0