Mac to git sd card backup script for pyramid

Hey - you may or may not find this useful or interesting, but I thought I’d share anyway. I wrote a little python script that I’m using to facilitate my backups of the pyramid sd card and I thought I’d share it with you. The script is a bit crude but might save you some time - that said, you’re still on the hook for setting up your backup environment which requires some technical skills. Also, this script has only been tested on osx but it likely works on linux - sorry windows users (maybe someone else will write the windows script or add multiplatform support to mine?)

For a long time I just used a single sd card and periodically I would just stick it in my mac and copy the contents to a folder with a label like “pyrabackup_”. After a couple of years I had this unwieldy pile of directories and I’m constantly deleting songs from the card to help me focus - this meant I had a file of directories and a song I deleted from the card, but might not want to delete forever is in some random dated directory. Now, you might ask why I used the dated directories and that’s because I wanted revisions - sometimes I want to restore a song to a previous version.

Then - to make matters more interested, I discovered a bug with sd card loading where the midi clock will hiccup slightly and stop my analog rytm. The workaround to this problem was to have less songs on an sd card - that said, I have a ‘live’ card for playing sets with songs that are done, and then i established a second sd card where i author new songs and it’s just got piles of saves on it as I regularly just try new things and don’t worry about how many songs I have. The second card extra complicated the backup scheme I was using as now what do I do? Do I merge the two cards together in a single directory when I do backups? Do I have even more of these datestamped directories?

Well, this was all too cumbersome for me to deal with and since I’m a software engineer who deals in revision control, I decided I would move to a single backup directory that was revision controlled via git. That said, manually copying files from multiple sd cards was cumbersome not to mention I got annoyed at running git commands all the time. Anyways - this is where the script comes in - it looks for differences in your backup dir versus your card and makes the backup directories match the card - then it stages, commits and pushes the changes to your local and remote git repos. Since I just wrote it for me it’s fairly inflexible around this pipeline, though I don’t mind adding an option to turn off the push/commit if anyone ends up finding it super useful:

(god I need to change that picture - anyways)

Anyways - there’s some lengthy setup still so I’ll only do proper packaging if more than two people end up interested in this. Here’s what you need to have on your osx/linux system (homebrew can do all these installations for you on a mac, just google homebrew to set it up):
:: Setup your git repo ::
* Install git
* Go onto github/gitlab (or your favorite git hosting site) and make yourself an account, then make a new repo - I call mine “pyra_back”
* Clone your repo locally
* For giggles you should make sure you can push files to your remote, my script will ignore anything that’s not a prefixed “PYRA” dir so, you can just make a text file or something and commit/push it to make sure things are working.

Everything working with git? Good!

:: Setup Python and the script ::
* Install python 3.8 or newer and make sure it resolves to ‘python’ on your command line (type python in your terminal and if it doesn’t say 3.8 then you need to deal with this)
* Install pip
* pip install checksumdir

At this point just try running the script, “pyra_back.py -h” and you should get help output, if you don’t, your python isn’t setup right. Then you can just stick your memory card in and run the command like so:

./pyra_back.py --backup-folder --pyra-card

On a mac your card will get mounted fo /Volumes and I keep my git repo on my desktop cause i’m a lazy developer, so mine looks like:

./pyra_back.py --backup-folder /Users/carl/Desktop/pyra_back --pyra-card /Volumes/PYRAMID_2

Anyways, this is hardly a painless install and it does require some technical know-how but if you’re doing complicated backups it might be worth your afternoon to set all this up. And I mean I wrote the script yesterday, there’s bugs and enhancements of course - so if you already have a git repo hopefully the script doesn’t have a bug that destroys it, but it is git so you can always just rollback if something happens.

Apologies in advance if there’s a bug, but let me know and I might fix it for you. My next step is to convince my mac to run this automatically when I insert the card but I’m probably not going to do that any time soon.

If you’re curious - the script works by looking at every PYRA directory found on the card and in the git repository. If a PYRA directory isn’t in the git repo it just copies it. If a PYRA directory is on both the card and in the git repository it runs an md5 to compare the two. If there’s a difference it copies the contents of the PYRA directory to the git repository and then deletes any track files in the git repository not found on the card. Then, after it’s done this for all PYRA directories runs a git add, commit, and then push in that order. The commit message is just a timestamp that says when the backup was made.

Oh and it’s currently not backing up txt files - so if you have your definition files you just wanna handle those by hand for right now. If someone really wants that, I’ll add it for you.

Cheers!

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.