Backup Flows To Google Drive Only If Modified

Share and discuss your flows and ideas with other users.

Moderator: Martin

jjts
Posts: 4
Joined: 29 Jan 2018 03:25

Backup Flows To Google Drive Only If Modified

Post by jjts » 31 Jan 2018 03:42

Hi all,

I'm new at Automagic so bear with me! I liked the default backup flow that comes with Automagic but wanted to backup daily and to the cloud. Then I got to thinking, it is silly to backup every day if nothing's changed, so I modified the default backup script and came up with this:

Edit - new link to working file:
http://automagic4android.com/flow.php?i ... 1ed3d4e12e

Here's what it does:
- copies the existing current backup file to old
- copies the current hash, if it exists, to old hash
- backs up current widgets and flows to a file
- reads both current and old widget files into memory
- hashes the two files if necessary and compares the hashes
- if the hashes don't match, there was a change to the file, so it uploads the current flow backup xml to a timestamped version on the server

Usage:
If you want to use this, you'll need to do a couple things:
1) create 2 blank files, /storage/emulated/0/flows_widgets_backup-CURRENT.xml and /storage/emulated/0/flows_widgets_backup-OLD.xml (I used the Terminus app with the touch command)
2) change the Google account in the last step of the flow to your own

Please let me know of any feedback or if anything could be improved. I know I should create the empty files if they don't exist, and I may just do that with with an updated version.
Last edited by jjts on 07 Feb 2018 04:26, edited 1 time in total.

User avatar
DRAGO
Posts: 6
Joined: 28 Oct 2016 17:57

Re: Backup Flows To Google Drive Only If Modified

Post by DRAGO » 04 Feb 2018 20:21

Kann ich nicht importieren."Datei ist ungültig"

karthikn130
Posts: 7
Joined: 19 Mar 2016 13:54

Re: Backup Flows To Google Drive Only If Modified

Post by karthikn130 » 06 Feb 2018 03:51

Automagic says "Could not import flows. This file is not valid." So kindly reupload the flow or upload screenshot of the flow.
Thanks.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Backup Flows To Google Drive Only If Modified

Post by Desmanto » 06 Feb 2018 06:46

It seems he edited the xml manually before sharing. I check the xml is properly formatted in automagic format. Open using hex editor, there is no inproper BOM. Turns out to be the email part, where he replace his email with <MYUSERNAME>@gmail.com. <> are illegal characters in email address. Worse is it is properly enclosed, making it to be viewed as a valid xml tag, but not closed properly. Well, even it is closed properly using </MYUSERNAME>, it will still corrupt when imported.

So meanwhile it hasn't been fixed, you can fix it by yourself by using any text editor.
1. Open the flow.xml using any text editor, I just use MiXplorer Text editor
2. Find for <MYUSERNAME>@gmail.com. (it is at line 52 if using MiXplorer).
3. Remove the less-than and greater-than sign, leaving it : MYUSERNAME@gmail.com
4. Save the file and import it again. It should import properly now.

This is the SS of the flow.
Screenshot_2018-02-06-13-40-06_Half_Clean.png
Screenshot_2018-02-06-13-40-06_Half_Clean.png (88.7 KiB) Viewed 26431 times
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

karthikn130
Posts: 7
Joined: 19 Mar 2016 13:54

Re: Backup Flows To Google Drive Only If Modified

Post by karthikn130 » 06 Feb 2018 18:24

Thank you for your reply. It worked as expected and Thanks for your time.

jjts
Posts: 4
Joined: 29 Jan 2018 03:25

Re: Backup Flows To Google Drive Only If Modified

Post by jjts » 07 Feb 2018 04:28

Desmanto wrote:It seems he edited the xml manually before sharing. I check the xml is properly formatted in automagic format. Open using hex editor, there is no inproper BOM. Turns out to be the email part, where he replace his email with <MYUSERNAME>@gmail.com. <> are illegal characters in email address. Worse is it is properly enclosed, making it to be viewed as a valid xml tag, but not closed properly. Well, even it is closed properly using </MYUSERNAME>, it will still corrupt when imported.
My apologies, yes, I had edited out my email address for privacy. Link in the original post is fixed now.

yxd0018
Posts: 85
Joined: 05 Dec 2018 15:14

Re: Backup Flows To Google Drive Only If Modified

Post by yxd0018 » 07 Dec 2018 12:34

Does your Google drive upload still work? I have error with correct Gmail account and various paths:

07.12.2018 07:24:59.274 [Manual Test] End executing action 'Google Drive Upload Files: /storage/emulated/0/flows_widgets_backup-CURRENT.xml to /backups' and exception Unknown
07.12.2018 07:24:59.326 [Manual Test] Flow ends execution due to errors
07.12.2018 07:24:59.326 [Manual Test] Error:
ch.gridvision.ppam.androidautomagiclib.util.m: Unknown
at ch.gridvision.ppam.androidautomagic.model.a.bh$1.b(SourceFile:382)
at ch.gridvision.ppam.androidautomagiclib.util.ci$1$1.run(SourceFile:52)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6623)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: com.google.android.gms.auth.GoogleAuthException: Unknown
at com.google.android.gms.auth.zzh.zze(Unknown Source:132)
at com.google.android.gms.auth.zzg.zzd(Unknown Source:21)
at com.google.android.gms.auth.zzg.zze(Unknown Source:77)
at com.google.android.gms.auth.zzg.getToken(Unknown Source:3)
at com.google.android.gms.auth.zzg.getToken(Unknown Source:5)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source:0)
at ch.gridvision.ppam.androidautomagic.util.a.a.<init>(SourceFile:76)
at ch.gridvision.ppam.androidautomagic.model.a.bh$1.a(SourceFile:199)
at ch.gridvision.ppam.androidautomagic.model.a.bh$1.c(SourceFile:174)
at ch.gridvision.ppam.androidautomagiclib.util.ci$1.run(SourceFile:40)
at java.lang.Thread.run(Thread.java:764)

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: Backup Flows To Google Drive Only If Modified

Post by anuraag » 07 Dec 2018 14:30

Looks like Automagic don't have permission to your google drive.
Try opening action "upload to google drive" and verify account access.

yxd0018
Posts: 85
Joined: 05 Dec 2018 15:14

Re: Backup Flows To Google Drive Only If Modified

Post by yxd0018 » 07 Dec 2018 20:40

I chose Google account without seeing any permission popup. But I get Google drive access error. Could be my automatic 2017 version old?

anuraag
Posts: 371
Joined: 24 Jan 2015 02:06

Re: Backup Flows To Google Drive Only If Modified

Post by anuraag » 07 Dec 2018 23:06

Why are you using old version?

Post Reply