keep certain number of backup file

Share and discuss your flows and ideas with other users.

Moderator: Martin

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

keep certain number of backup file

Post by yxd0018 » 12 Jan 2019 13:24

I'm using google drive(experimental) to backup flow everyday. I use date as part of file name. I wonder if there is a way to keep last 3 backup file in gdrive.
Option2 is if it's not available, is there a sample flow to do the same thing on local drive then I can delete all the files on gdrive, upload local copies.
Option3 will be keep desired copies locally then use foldersync to sync to gdrive.

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

Re: keep certain number of backup file

Post by Desmanto » 12 Jan 2019 17:37

Just init file list the Gdrive folder after you upload. Then check if the list length is more than 3, delete the oldest one.

I have a very complex idea about the backup flow to store 1 week and some special backup. But again, I was distracted and never complete it until now.
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.

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

Re: keep certain number of backup file

Post by yxd0018 » 12 Jan 2019 20:16

Can you share your generic clean up flow? I guess I need to write script to sort by timestamp in desc order, right?

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

Re: keep certain number of backup file

Post by Desmanto » 13 Jan 2019 17:48

I am back editing my AM backup flow as your reply yesterday. Finally finish it partially, but was distracted too to complete 2 of other flow parts, in order to help creating this flow :lol: I need some time to try and use the my flowception to help testing the backup. Only then, I will share it (Although haven't finish all, but at least fully functioning for the finished part).

The core function of the removing is simply Action Init variable file list (in your case the gdrive list). The result is list of the files, sort by name. Since you use the date as part of the name, the oldest one will be the first one on the list. Simply create a script after the init

Code: Select all

dellist = newList();

if(length(files) > 3)
  addElement(dellist, files[0]);
This will check if the list of files is more than 3, then add the first element (the oldest one) to the delete list. Use {dellist} in action Delete files, after the script. (in your case delete from gdrive). you might want to try in in local folder first, and make sure you copy the folder as backup and as test files.
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.

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

Re: keep certain number of backup file

Post by Desmanto » 20 Jan 2019 18:19

I have tested the backup flow and it is running great. Now I have daily and manual backup flow. You can modify it to suit your need
Automagic Backup : viewtopic.php?f=3&t=7858
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.

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

Re: keep certain number of backup file

Post by yxd0018 » 20 Jan 2019 22:27

That's terrific. I will try out tonight.

Wibbly
Posts: 418
Joined: 17 Mar 2014 09:02

Re: keep certain number of backup file

Post by Wibbly » 21 Jan 2019 09:10

yxd0018 wrote:I'm using google drive(experimental) to backup flow everyday. I use date as part of file name. I wonder if there is a way to keep last 3 backup file in gdrive.
Option2 is if it's not available, is there a sample flow to do the same thing on local drive then I can delete all the files on gdrive, upload local copies.
Option3 will be keep desired copies locally then use foldersync to sync to gdrive.
You may find Google Drive's native file version history feature will work so you can get back to previous versions of the same file without having to manage it yourself.
https://support.google.com/drive/answer ... ktop&hl=en

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

Re: keep certain number of backup file

Post by yxd0018 » 21 Jan 2019 09:35

Thanks.
Between keeping different files by myself and trusting Google versioning system with the same file name, I found the former easier and more reliable.

Wibbly
Posts: 418
Joined: 17 Mar 2014 09:02

Re: keep certain number of backup file

Post by Wibbly » 21 Jan 2019 10:41

yxd0018 wrote:Thanks.
Between keeping different files by myself and trusting Google versioning system with the same file name, I found the former easier and more reliable.
Have you had problems with Google's versioning actually not working?

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

Re: keep certain number of backup file

Post by yxd0018 » 21 Jan 2019 17:34

after testing the versioning system in gdrive, I changed my mind and use that. Thanks.

Post Reply