Recently, I migrated one of the companies that I work for to Office 365. As some of you may know - Office 365 packages come with the OneDrive service that provides 25GB of online storage.
So up until the migration - the users' data was automatically synchronized to the in-house file server (using Offline Files). There is a great many ways to synchronize data from a user's machine to a network location - from using Offline Files, to scripting, to third party software. In this scenario I will talk about synchronizing to both a local network location and a cloud service (OneDrive for Business in this case) without using any third party software.
First, let me point out that OneDrive currently provides one sync folder on the computer where everything that you want synced has to go. You cannot designate other folders to be synchronized to OneDrive unless you copy them to the sync folder and continue to work from there. So let's say you do that but you'd still want the same data synchronized to your local file server. And you don't want to use third party software that may create system instability, or load it up.
So, we're going to accomplish this task by using a Robocopy monitoring script that will be running invisibly in the background. All the time.
So we create a batch script that will contain the following:
@echo off
robocopy "Source OneDrive Folder" "Destination network folder" /MIR /COPY:DT /MON:1
robocopy "Source OneDrive Folder" "Destination network folder" /MIR /COPY:DT /MON:1
Now (assuming your system partition is C:), your source OneDrive folder is usually located at
C:\Users\username\OneDrive
or
C:\Users\username\OneDrive for Business
Your destination should be a local folder or a network share. Don't forget the quotation marks.
You might also need your shared folder credentials if the share is password protected, so to log into the share correctly the script would have to present the correct credentials. To do that you will have to add a line that logs into the share (before the Robocopy command):
net use \\servername /USER:username password
After the Robocopy command you might want the script to log out, using the following command:
net use \\servername /d
This is a syncing script, that's why we're using the /MIR switch, this means that if we delete the file in the source folder, the file will soon be deleted in the destination folder. If you wish to copy files and not sync them, you can use /E /COPY (or /COPY:DT) instead of /MIR.
I also should mention that /COPY:DT switch in the above script is optional, it instructs Robocopy to preserve the files' Date and Time stamps but not attributes. I just prefer using it in this situation for better stability.
Now we can save the script as a BAT or a CMD file and run it (preferably in elevated mode) to see how it works. The script will never close unless the command prompt is closed manually, so this may create an annoyance to the user. That's why it may be a good idea to automate it's execution and keep it hidden from the user.
To do that we go into Task Scheduler and create a task to run this script. I recommend the trigger being the user's logon. Because if the trigger is a certain time of day - there may be duplicates of the same process, because the process never stops anyway.
Make sure you set the SYSTEM account as the account running the task, and mark it Hidden. This will allow the script to run invisibly in the background. This starts the cmd.exe and robocopy.exe processes and they only take a few hundred kilobytes in memory.
You can also check out my post on how to sync network shares to OneDrive automatically.
Awesome thx. Huge help.
ReplyDelete
Deletebuy office professional project 2013 keys
cheap windows server 2016 product key online
Online Windows 10 Pro Product Key Store
buy office 2016 Professional Plus keys online
office project product key download
Sync Files To Onedrive And A Local Server Together Automatically. >>>>> Download Now
Delete>>>>> Download Full
Sync Files To Onedrive And A Local Server Together Automatically. >>>>> Download LINK
>>>>> Download Now
Sync Files To Onedrive And A Local Server Together Automatically. >>>>> Download Full
>>>>> Download LINK 4G
Always glad to help.
ReplyDeleteThis is great. Is it possible to have two-way syncing?
ReplyDeleteIn what scenario would you want it to two-way sync?
DeleteHi Serge,
ReplyDeleteI would like to have my work PC syncing a Network Share (with other users creating & editing files) to my Onedrive.
At home, on my laptop, I can see the Files on my Onedrive, but would like to edit them and have it update the Network Share in turn.
Brian.
Hi Brian,
DeleteSo essentially you would like to create a portal to your network share through OneDrive. That's not what this is for and it's not an efficient way of going about it.
This post talks about backing up your data to the cloud, so it is not located in just your office.
What you are talking about is simply a remote access to your office's server. And for that there are numerous better ways to set it up. Such as a VPN connection, or an FTP connection.
I don't see the need to employ OneDrive for this scenario.
Serge
Yeah, I was hoping to avoid VPN for this particular instance, but I agree.
ReplyDeleteGreat tutorial though, cheers.
I'm guessing you'd like to work from home, and you'd wanna involve the IT department to set it up..? :)
DeleteThanks for sharing info. Keep up the good work...We hope you will visit our blog often as we discuss topics of interest to you
ReplyDeletedata protection
I found this is an informative blog and also very useful and knowledgeable. I would like to thank you for the efforts you have made in writing this blog norton.com/setup
ReplyDeleteSync Files To Onedrive And A Local Server Together Automatically. >>>>> Download Now
ReplyDelete>>>>> Download Full
Sync Files To Onedrive And A Local Server Together Automatically. >>>>> Download LINK
>>>>> Download Now
Sync Files To Onedrive And A Local Server Together Automatically. >>>>> Download Full
>>>>> Download LINK