Gambas Backup Folder App

Post

Posted
Rating:
Item has a rating of 5 (Liked by sholzyLiked by Poly)
#1 (In Topic #1847)
Avatar
Regular
cage is in the usergroup ‘Regular’

For Copying Folder From One Drive to Another

Selection_001.png

A simple Folder copying program that copies folders from one drive to another drive or USB stick.  Also can make copying in reverse.

This program was originally made with Arch Linux and remade with Linux Mint.

Here is a pdf file wiith step by step instrutions on how to use the Backup application.
Had to post it as a zip file, for some reason it wouldn't accept it as just a PDF

Attachment

GambasBackup.pdf.zip




There are two modes of copying.
 
  1. Home drive to backup drive or USB
  2. Backup Drive or USB to Home drive.
The direction of the switch tells you which way the copying will go plus the button names will change alos.
Feel free to modify it to your liking.

Home you find this little app useful. 
Attachment

BackupDir6.zip

Last edit: by cage

Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Expert
Poly is in the usergroup ‘Expert’
Thanks for your program, but I just tried it out.
It doesn't copy hidden files for me.
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Expert
Poly is in the usergroup ‘Expert’
Just delete this in line 133

Code

tbsource.Text = Dialog.Path & "/*"

the & "/*"

and use this instead

Code (gambas)

tbsource.Text = Dialog.Path
You already specify in the line 84

that you want to copy all files and all folders “-r”.

Code

TermCmd = "cp -avrup " & Source & " " & Destination


Last edit: by Poly

Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Regular
cage is in the usergroup ‘Regular’
Thanks Poly. At one time I had the same thing you sugested but found that it didn't copy the way I wanted.  Everyone's distros do have slight differences and that is why I posted the code.  I am glad you got it working for you.  The /* is a left over from when I was using Arch Linux but works fine with Linux Mint.  Everyone is free to modify the program to what suits them. When I created this program was because I didn't need a program that backed up everything and compressing the data.  I only use it to backup Folders that have changed with changes I made to them.  
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Expert
Poly is in the usergroup ‘Expert’
Hi Cage,

Thanks again for the program.  :thumbs:
I didn't know there were such differences between the distributions.
I also didn't mean to sound like a know-it-all or anything.
I just tried to back up my Gambas projects right away and noticed it immediately.
I thought that you probably used it for normal files and that's why you hadn't noticed it yet.
But I find the different behavior very strange and also unpleasant. How are people supposed to write programs that multiple people use?
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by gbWilly)
#6
Avatar
Administrator
sholzy is in the usergroup ‘unknown’

Poly said


But I find the different behavior very strange and also unpleasant. How are people supposed to write programs that multiple people use?


If your target isn't a particular distro, then you should test on multiple distros to ensure it works correctly.

sholzy
Gambas One Site Director

To report bugs in the Gambas IDE:
Official Gambas Bug Tracker
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by gbWilly)
#7
Avatar
Administrator
sholzy is in the usergroup ‘unknown’
@cage - can you edit your first post to include the Gambas version (and distro) your program was designed with?

Sometimes creating a project with the latest and greatest Gambas version can leave out a lot of users that are still on older Gambas versions.
 

sholzy
Gambas One Site Director

To report bugs in the Gambas IDE:
Official Gambas Bug Tracker
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Yogi)
#8
Avatar
Expert
Poly is in the usergroup ‘Expert’
But I just took another look at it and don't think it's a distro-specific thing.
It's clearly a matter of Bash syntax.

And there are simply two different approaches.
Just enter the following in a directory:
 ls -al
 ls -al *
 ls -al .*

In Bash, a filename beginning with a ' . ' must be specified explicitly. It is not enclosed by an ' * '.
For this reason, hidden files and folders are not listed either.

So, if I am in a directory where only visible directories and files are present, I can only copy all directories using & “/*”.
Only these visible directories and their contents, including the hidden files within them, are copied, but not the directory itself.

However, if I want to copy an entire directory with all hidden files and folders in it, as well as the directory itself, I have to omit the & “/*”.

If I only want to copy the hidden files and folders along with their contents, I would have to use
& “/.*”.


So if the whole thing is a backup tool and I want to copy the individual files that are newer than those in the destination folder to the destination folder that has already been created, this is only possible with the addition of & "/*”.
If I want to back up an entire folder with all hidden files in it, it should be omitted.
As cage already said, there are different requirements and purposes for this program. But you should know what you want, so this discussion here might be helpful for some people.

Last edit: by Poly

Online now: No Back to the top

Post

Posted
Rating:
#9
Avatar
Regular
cage is in the usergroup ‘Regular’
Poly when you copy the hidden folder are you copying to anothe folder? Myself I create a backup folder then copy the contents of the hidden folder to the newly created folder. When I do this everything in the hidden folder copies over but it will still all be hidden.  If you turn on view hidden folders with your file manager you should see it there.  Don't worry, I didn't take any offense to what you said, just glad you are having fun. As for me I use currently Linux Mint XFCE but created the program in Arch Linux. I am currently using Gambas 3.20.4 to write my programs.  The Backup program works both on my desktop and laptop.  :)
Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Regular
cage is in the usergroup ‘Regular’
Sholtzy I posted that info in the first post.  As for older versions of Gambas the program was written with Gambas 3.20.4 when I was using Arch Linux.  When I first went back to Linux Mint it used 3,19.6.  The program ran fine after recompilling and later after I managing to upgrade to 3.20.4. How ever it is important to either create a backup folder before hand or do it by right clicking the Select Folder and click on create new folder.  Feel free to modify the program to your likeing.  The only question I have is how well this program would run in Debian.  Guess I will have to load it up in a virtual machine and find out.  
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Poly)
#11
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

cage said

Sholtzy I posted that info in the first post.  As for older versions of Gambas the program was written with Gambas 3.20.4 when I was using Arch Linux.  When I first went back to Linux Mint it used 3,19.6.  The program ran fine after recompilling and later after I managing to upgrade to 3.20.4. How ever it is important to either create a backup folder before hand or do it by right clicking the Select Folder and click on create new folder.  Feel free to modify the program to your likeing.  The only question I have is how well this program would run in Debian.  Guess I will have to load it up in a virtual machine and find out.  
Cage, I think Poly already did run in in either GambOS (Debian MATE) or Devuan (Debian using init instead of systemd), so Debian  :thumbs:

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#12
Avatar
Expert
Poly is in the usergroup ‘Expert’
cage , I really don't think it's because of the different distributions, because you're using clear Bash syntax.
If you use /* , then it can't refer to any files or folders located in this directory, because
the * explicitly does not stand for a .
But if it is a folder that itself contains hidden files, then these are all included, but that is due to the -r option.

But please, maybe I was a little too hasty in my initial comments.
Thank you very much for the program, it has a nice interface and is easy to use.
Precisely because I find it so successful and extremely useful, I will continue to use it in the future.  :thumbs:

You give everyone the freedom to change it as they wish, but I just wanted to point out a small detail here.
At least on my GambOS system, I had the following problem.
And since GambOS plays a major role on this site and will hopefully become more and more popular,
I'll try to explain it clearly here.

Given:

Directory “Tools”
It contains  the directories

Picture
Texts
and the hidden directory
.cache

Your destination folder is: /media/usb/Backup

With the & “/*”,

you would only copy the folders Picture and Texts, including all hidden files located in this folder.
These two folders would be located directly in the Backup folder.
But not the hidden folder .cache

So it would not be backed up.

If you omit the & “/*”,

you would get a folder called Tools in the /media/usb/Backup folder,
meaning that the folder itself would also be copied.
However, you would find all folders in it, including the hidden .cache folder

So these are indeed two different ways of copying, and I agree with you that it is desirable to create a separate backup folder and only want to have backed up folders and files in it, but not the original folder.

Perhaps it would not be a bad idea to perform a two-step backup.
In the first step, you back up with & “/*” as before,
and then do a second run with & “/.*”
to back up only the hidden files.
To stay with the example, only .cache.

To do this, I simply created a second
source variable in your program.

Code

Source1 = tbsource.Text & “/*”
Source2 = tbsource.Text & “/.*”
and then adjusted the command for copying.

Code

TermCmd = “cp -avrup ” & Source1 & “ ” & Source2 & “ ” & Destination
If you don't need it, this tip might be helpful to others in preventing data loss.
Because the program is simply too useful.  :thumbs:

So, once again, thank you for posting it here and not keeping it to yourself.  ;):)
 
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Poly)
#13
Avatar
Regular
cage is in the usergroup ‘Regular’
Thank you Poly for your response.  If you have it working for you then I am very happy.  I am happy that you found that program useful to you and think once you have it working like the you like it then post your version for other to enjoy.  I down loaded Gamas OS this morning and will do some testing of my own.  

Sincerly Cage
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Poly)
#14
Guru
BruceSteers is in the usergroup ‘Guru’
Handy thing to have.

Did you ever look into rsync ?
rsync - Wikipedia
Try rsync –help to see all it's features.
(it's designed for syncing 2 folders so probably offers many more arguments for managing dir backups than cp does, and handles only copying modified files)

Respects
Online now: No Back to the top

Post

Posted
Rating:
#15
Avatar
Regular
cage is in the usergroup ‘Regular’
Bruce I did at one time but found that the copy command actually made faster copies.  I have made a how to for the backup program in the original post.
 
Online now: No Back to the top

Post

Posted
Rating:
#16
Avatar
Administrator
sholzy is in the usergroup ‘unknown’

cage said

Bruce I did at one time but found that the copy command actually made faster copies.  I have made a how to for the backup program in the original post.
 

Your PDF didn't survive being added.  ;)

sholzy
Gambas One Site Director

To report bugs in the Gambas IDE:
Official Gambas Bug Tracker
Online now: No Back to the top

Post

Posted
Rating:
#17
Avatar
Regular
cage is in the usergroup ‘Regular’
Thanks for the infor on the pdf.  Don't know what happened but I will try and post it later when I can get back into my desktop.

Update:

For some reason the PDF would not take so I zipped it and attatched it to the first post.

Last edit: by cage

Online now: No Back to the top

Post

Posted
Rating:
#18
Avatar
Regular
cage is in the usergroup ‘Regular’

BruceSteers said

Handy thing to have.

Did you ever look into rsync ?
rsync - Wikipedia
Try rsync –help to see all it's features.
(it's designed for syncing 2 folders so probably offers many more arguments for managing dir backups than cp does, and handles only copying modified files)

Respects


Bruce I took another look at rsync and incorporated it another version.  Been playing around with some of it's tributes. Seems it's working out fine.  
Online now: No Back to the top
1 guest and 0 members have just viewed this.