Backup script - replace only files with certain extension

I have a small video production company and a bottleneck we’re having is with regards to file backup.

What happens: weekly I ask my collaborators to backup their SSD’s on our central computer, this computer has a shared Backup Folder on the LAN.

How this backup is done nowadays: The contributor copies all the folders from the root of his SSD to the folder with his name located inside the Backup folder central computer and asks to replace everything.

Yeah, that’s not optimized at all…

The structure of employee SSDs: Every employee has an M.2 SSD, the device name always follows this rule "Company Name - Employee Name"

Backup folder structure on the central computer: Backup folder path is \\192.168.0.130\Backup\Employee Name

What I would like to do: I would like to create a script that follows some rules to copy the files to the backup folder.

Rules:

Copy all files from that storage unit, but only replace files with the extension .pr, .ae, .psd, .psb, .ai

Path to copy files:

\\192.168.0.130\Backup\GET-THE-NAME-OF-THE-STORAGE-UNIT-EMPLOYEE

For example, if the drive is called "Company Name - Aaron Trevor", copy the files to the "Aaron Trevor" folder inside the Backup Folder on the central computer.

The idea is that this executable script is at the root of every M.2 SSD.

What’s the best way to do this?

I have a very basic knowledge in the area of ​​programming, so what came to my mind at first was to create this script in a notepad and run it as Powershell or Batch file, but I don’t know if it’s the best way and I don’t have enough knowledge to craft this code myself

If anyone can help me, I will be very grateful, it will help a lot in everyday life.

I ask that the explanation be as detailed as possible, as I said, I have little knowledge in the area, but I want to evolve and create other things from it.

Tyrone,
Welcome to the forum. :wave:t4:

Since you have only basic knowledge about scripting every solution you could come up with would be very basic as well. And on top of that hard for you to maintain and error prone.

I’d recommend to search for a backup tool what’s easy to understand and to configure. There you have a GUI and maybe even support if something goes wrong.

In general this forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.

We actually expect you to make an own attempt at the first place to get your task done or to solve your problem. If you have done so already please document here what exactly you have done and show your code. Then we probably might be able to help you step further.

Hello, Olav!
Thank you so much for the welcome!

I’m not so beginner as to depend on some software to do what I want, I don’t have advanced knowledge in programming languages ​​but I know the basics of some.

The thing is, no GUI software does what I need, I’ve done a lot of research, besides that, I want something practical, like: clicked > it’s done!

Another point to take into consideration, I have a good knowledge of IT, so I take care of all the infrastructure of the production company’s network and computers of my production company.

It’s hard to find good IT professionals nowadays in my country, most of them cause more problems than they solve… and I’m a person who strongly believes in the philosophy “If you want something done right, do it yourself!”.

Taking this into account, I would like to understand how I can elaborate this script, because from it I can create others.

I have a robocopy script that works very well so far, the point is that I would like to make it a little more advanced, and I believe the way is to integrate powershell into it.

My current script:

chcp 1252
set /p dummy=Tecle ENTER para continuar

robocopy  /e /zb /v /sec /copyall "E:\My Company - Aaron Trevor\02. Clients " "\\192.168.0.130\Backup\Aaron Trevor" /xd "03. Proxy" /xf *.avi

set /p dummy=Backup efetuado com Sucesso! Tecle ENTER para finalizar.

As you can see, the Backup folder path is hard-coded in the code, what I wanted is for it to be flexible according to the SSD name.

As I explained, I would like the script to detect the name after the dash and copy the files to the folder with the contributor’s name inside the backup folder.

For example, if the SSD name is “My company - Aaron Trevor” the script will copy the files to the folder “\192.168.0.130\Backup\Aaron Trevor”

Why?

Because if at some point the backup path changes, I will have to create a specific backup file for each contributor instead of creating just one and asking everyone to replace the file at the root of the SSD.

If you can help me with this, I would be very grateful!

So I’ve got you wrong when you said …

… Sorry. :wink:

If I haven’t got something wrong again should almost every backup software be able to do what you want. :man_shrugging:t4:

Do your users change their clients or do they work always with their own machine? If “yes” you would need to set up a basic backup solution once for each client and it would do its job from then on.

Since the code you shared is not PowerShell you’re actually in the wrong forum. :wink:

What exactly do you mean with that?

If that’s your actual question it’s quite easy.
If you want to split a given string in a dash character you can use the -split operator like this:

$SplittedSSDName = "Company Name - Employee Name" -split ' - '

I included the leading and trailing space character into the split pattern to get rid of the leading or trailing space in the resulting array items. Now you can access the second element of the resulting array with its index like this:

$SplittedSSDName[1]

Depending on your knowledge I’d recommend to do step back and start with learning the very basics of PowerShell first. This will save you from a lot of wasted time and frustrations.