updated backup/restore project

Here’s an updated version of a backup/restore program I wrote awhile ago. The first version worked, but it needed some changes. The changes I made are

1: the plist I use to get the project names is a seperate project and the only thing thats needed is the dependencies checked of the projects you want to backup. That project name needs to be plist or if you change the code, you can name it anything you want.

2: the backup file name is now created automatically. It has the format bkupmmdd-hhmm where mm is the month 01-12, dd is the day 01-31, hh the hour 01-23, and mm the minutes 00-59. So each time you do a backup, a new file is created. That file is saved as a text file in the folder Dropbox. You can delete any backup files you don’t want from the Dropbox folder. You can also sync any new backup files with the Dropbox app using sync from the Dropbox folder.

3: Running the code and selecting what you want to do is also easier. I added comments on the screen to guide you thru the steps. One button creates the backup file and the other buttons allow you to see all your backup file names, select which backup you want to use, and which project you want to extract.

4: You can only extract 1 project at a time, but you can extract as many projects as your memory allows, creating a new tab for each project.

5: So the steps are, create a project called plist and check the dependencies of each project you want to backup. Run the backup program and tap Create a backup file. You’ll see a list of projects saved, the backup file name, the number of projects saved, and the file size. To extract a project, tap Show all backup files, to see a list of all your backup files. Tap on one of them to select it, then tap Show saved projects. Tap on the project you want to extract and tap Extract. You’ll see a message saying a tab for that project was created. You can extract more projects if you want. To complete the extract, you need to exit the program back to the editor. There you’ll see a tab for each project you extracted. Tap the tab you want, then you’ll need to select all the code, and copy it. Exit the project and long press Add new project until you see Paste into project. Enter the project name and press Create. A lot of this would be easier if we could create a project from within the program. Since this is new code, there may be problems. Play with it until you are comfortable with it. If you find any problems, let me know.

Here’s a link to the program.

Link removed, see next post.

EDIT: Any tab that’s created for an Extract will automatically be removed when the backup program is executed.

I just found a problem with my code. If a project contains a --# Main or any other tab with the --#, duplicate tabs will be created when doing the Paste into project. I’ll repost the link after I correct the problem.

EDIT:
Here is a new link with updated code. If a tab already contains a --# Name, then I won’t add another one. The --# Name is required to use the Paste into project option.

https://gist.github.com/dave1707/09a1c1b989efd800f658

If you created any backup files with a previous version, those won’t work with this version.

This happens for me by pressing the backup files:

Main:65: bad argument #1 to 'gmatch' (string expected, got nil)
stack traceback:
	[C]: in function 'string.gmatch'
	Main:65: in function 'createProjectTable'
	Main:39: in function 'startBackup'

@TokOut Did you create a project called plist and use the dependencies drop down to check the files you want to backup. Read step 1 above. That’s the error message when it can’t find a plist file.

When i try to synch with dropbox, i get an error message saying it cannot get the file list info from dropbox. If i try a second time then codea exits to ios. The problem is not related to daves backup code, it happens all the time. I deleted the dropbox app and reinstalled it but that did not help. Any ideas?

There have been a lot of Dropbox updates, but so far I haven’t run into your problem. One thing I noticed, sometimes when I look in the Codea Dropbox folder, it will be empty and I have to do a sync for before the items will show. Not sure what’s causing that and I haven’t tried yet to track down the cause.

I prefer to use Backup& Restore Dropbox plugin on WordPress for all my files. I just need to link it to my Dropbox account and it automatically backs everything up. And so far everything has been smooth. https://wordpress.org/plugins/dropbox-backup/

@betty How does it get your Codea projects to back them up.