Gambas Backup Folder App
Posted
#1
(In Topic #1847)
Regular

For Copying Folder From One Drive to Another
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
GambasBackup.pdf.zip
There are two modes of copying.
- Home drive to backup drive or USB
- Backup Drive or USB to Home drive.
Feel free to modify it to your liking.
Home you find this little app useful.
BackupDir6.zip
Last edit: by cage
Posted
Expert

It doesn't copy hidden files for me.
Posted
Expert

Code
tbsource.Text = Dialog.Path & "/*"
the & "/*"
and use this instead
Code (gambas)
that you want to copy all files and all folders “-r”.
Code
TermCmd = "cp -avrup " & Source & " " & Destination
Last edit: by Poly
Posted
Regular

Posted
Expert

Thanks again for the program.
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?
Posted
Administrator

Poly said
But I find the different behavior very strange and also unpleasant. How are people supposed to write programs that multiple people use?
From “Post #12,640”, October 21st 2025, 7:32 PM
If your target isn't a particular distro, then you should test on multiple distros to ensure it works correctly.
Posted
Administrator

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.
Posted
Expert

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
Posted
Regular

Posted
Regular

Posted
Administrator

Cage, I think Poly already did run in in either GambOS (Debian MATE) or Devuan (Debian using init instead of systemd), so Debiancage 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.
From “Post #12,671”, October 23rd 2025, 2:39 AM
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!
- 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!
Posted
Expert

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.
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 & “/.*”
Code
TermCmd = “cp -avrup ” & Source1 & “ ” & Source2 & “ ” & Destination
Because the program is simply too useful.
So, once again, thank you for posting it here and not keeping it to yourself.
Posted
Regular

Sincerly Cage
Posted
Guru

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
Posted
Regular

Posted
Administrator

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.
From “Post #12,690”, October 24th 2025, 3:30 PM
Your PDF didn't survive being added.
Posted
Regular

Update:
For some reason the PDF would not take so I zipped it and attatched it to the first post.
Last edit: by cage
Posted
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
From “Post #12,689”, October 24th 2025, 9:42 AM
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.
1 guest and 0 members have just viewed this.
