Automatic copy from one folder to another on the same NAS

Questions regarding using the Web File Manager, "File Station" and "File Browser" can be placed here
Forum rules
1) This is a user forum for Synology users to share experience/help out each other: if you need direct assistance from the Synology technical support team, please use the following form:
https://myds.synology.com/support/suppo ... p?lang=enu
2) To avoid putting users' DiskStation at risk, please don't paste links to any patches provided by our Support team as we will systematically remove them. Our Support team will provide the correct patch for your DiskStation model.
mathieu1425
I'm New!
I'm New!
Posts: 5
Joined: Tue Apr 07, 2015 7:27 am

Automatic copy from one folder to another on the same NAS

Postby mathieu1425 » Tue Apr 07, 2015 7:39 am

Hi all,

I have a Synology DS213+ and I am trying to do something that can sound pretty simple, but I could not find a way to do it so far...

I would like to push the content of folder A into folder B, on a regular basis (for example every Saturday night at 11.00pm), folders A and B being on the same NAS, but located in 2 different shared folders.

I tried to play with backup and restore app, with Cloud Station, but could not find an easy solution.

Could someone help me?

Thank you
mathieu1425
I'm New!
I'm New!
Posts: 5
Joined: Tue Apr 07, 2015 7:27 am

Re: Automatic copy from one folder to another on the same NA

Postby mathieu1425 » Tue Apr 07, 2015 9:53 am

SDirickson wrote:http://forum.synology.com/enu/viewtopic.php?f=116&t=98325&p=370460#p370460


Thanks for your reply, but I tried to use Data backup task as described there, but it does not allow to choose a specific target folder (only a specific target shared folder). I want my folder B to be somewhere specific within a shared folder...
Any idea?
SDirickson
Guru
Guru
Posts: 1462
Joined: Sun Mar 16, 2014 10:32 pm

Re: Automatic copy from one folder to another on the same NA

Postby SDirickson » Tue Apr 07, 2015 5:48 pm

I don't think any of the backup options exposed by DSM provide that level of specificity. You'll need to set up a cron job to copy the data.
mathieu1425
I'm New!
I'm New!
Posts: 5
Joined: Tue Apr 07, 2015 7:27 am

Re: Automatic copy from one folder to another on the same NA

Postby mathieu1425 » Wed Apr 08, 2015 12:14 am

SDirickson wrote:I don't think any of the backup options exposed by DSM provide that level of specificity. You'll need to set up a cron job to copy the data.


This is what I thought. Any experience in cron job you could share with me? I tried to write a script in a .sh file and launch it via the task scheduler (admin user or root user) but did not manage to make it work at all...

Here is the script I wrote:

SOURCE=/path_of_folderA/
DEST=/path_of_folderB

rsync -q -ax --delete $SOURCE $DEST/

Nothing seems to be happening ...
User avatar
akahan
Skilled
Skilled
Posts: 689
Joined: Sat Jul 14, 2012 6:52 pm

Re: Automatic copy from one folder to another on the same NA

Postby akahan » Wed Apr 08, 2015 12:24 am

Do you mind having the copying done by a Windows machine that's on the same network? You could set something up on the Windows machine to copy the contents of any folder you want on the Synology to any other folder.

It's not as elegant as having the Synology do it itself, but it'll work, so long as the Windows machine is powered on when you need it to be.
mathieu1425
I'm New!
I'm New!
Posts: 5
Joined: Tue Apr 07, 2015 7:27 am

Re: Automatic copy from one folder to another on the same NA

Postby mathieu1425 » Wed Apr 08, 2015 12:43 am

akahan wrote:Do you mind having the copying done by a Windows machine that's on the same network? You could set something up on the Windows machine to copy the contents of any folder you want on the Synology to any other folder.

It's not as elegant as having the Synology do it itself, but it'll work, so long as the Windows machine is powered on when you need it to be.


Thanks but I hope there might be a way to do it without going through another machine, cause I believe it would be slower, and as you mentioned, you need to have the machine powered on for the process to happen. I would like to copy big amount of data, so I am expecting it to take some time.

I am expecting to find a script that work and can be launched on a regular basis thanks to the Synology task scheduler. I just need some help to make it work the way I want. Thanks !
User avatar
akahan
Skilled
Skilled
Posts: 689
Joined: Sat Jul 14, 2012 6:52 pm

Re: Automatic copy from one folder to another on the same NA

Postby akahan » Wed Apr 08, 2015 12:49 am

In my experience, for what it's worth, using a Windows machine as a "middleman" makes the copying MUCH faster (about 5x) than any of the existing file transfer methods *between* Synologies, which are HORRIBLY slow. Not sure how it compares to "one folder to another on the SAME Synology," but I wouldn't necessarily assume that it would be a whole lot faster if managed internal to the Synology.
mathieu1425
I'm New!
I'm New!
Posts: 5
Joined: Tue Apr 07, 2015 7:27 am

Re: Automatic copy from one folder to another on the same NA

Postby mathieu1425 » Wed Apr 08, 2015 3:12 am

akahan wrote:In my experience, for what it's worth, using a Windows machine as a "middleman" makes the copying MUCH faster (about 5x) than any of the existing file transfer methods *between* Synologies, which are HORRIBLY slow. Not sure how it compares to "one folder to another on the SAME Synology," but I wouldn't necessarily assume that it would be a whole lot faster if managed internal to the Synology.


From what I read, Copy on the same NAS is much faster that when you use middle man... Anyway, I would like to keep this process 100% on the NAS, as my laptop will not always be switched on to take care of this... Thank you.

Anyone could guide me to make the script working as I want?
Thank you!
SDirickson
Guru
Guru
Posts: 1462
Joined: Sun Mar 16, 2014 10:32 pm

Re: Automatic copy from one folder to another on the same NA

Postby SDirickson » Wed Apr 08, 2015 3:31 am

mathieu1425 wrote:This is what I thought. Any experience in cron job you could share with me? I tried to write a script in a .sh file and launch it via the task scheduler (admin user or root user) but did not manage to make it work at all...

Doing cron stuff on Synology is harder than it should be: 'crontab -e' doesn't work because crontab (the program) doesn't exist (!?!?), and hand-editing of /etc/crontab by the unsuspecting will usually break it due to Synology's format requirements. This thread has info and scripts for doing things the Synology way.
rstark18
Trainee
Trainee
Posts: 16
Joined: Tue Apr 26, 2011 8:10 am

Re: Automatic copy from one folder to another on the same NA

Postby rstark18 » Mon Aug 10, 2015 5:58 am

Has anyone come up with a way to do this?
I came into the forum thinking that this should be a simple thing to do on my new NAS.
I thought I'd be able to use Task Scheduler to run a simple script that would compare two directories and sync them.
nipmads
Trainee
Trainee
Posts: 12
Joined: Sat Mar 10, 2007 12:30 am

Re: Automatic copy from one folder to another on the same NA

Postby nipmads » Tue Sep 15, 2015 5:38 am

I also hoped to find a solution via this thread :-)

I'm looking for something just like this feature.

In my case, to replicate files and folders to a Dropbox sync directory on a specific schedule.
rstark18
Trainee
Trainee
Posts: 16
Joined: Tue Apr 26, 2011 8:10 am

Re: Automatic copy from one folder to another on the same NA

Postby rstark18 » Tue Sep 15, 2015 6:41 am

nipmads wrote:I also hoped to find a solution via this thread :-)

I'm looking for something just like this feature.

In my case, to replicate files and folders to a Dropbox sync directory on a specific schedule.


I did not come up with a solution that relies on the NAS to perform this. My solution (as was suggested by someone in a preious post) was to use my backup program (Syncback SE) to do a mirror of the NAS folders in the morning after it does it's backup tasks.

It crazy that a decent NAS like Synology doesn't have this ability as an easily selectable function. MY super cheap NAS (iomega IX2-200CE) that I was using before had much more user friendly features and allowed this.
User avatar
gwknight
Trainee
Trainee
Posts: 10
Joined: Fri Aug 28, 2015 2:14 am

Re: Automatic copy from one folder to another on the same NA

Postby gwknight » Wed Sep 16, 2015 12:07 am

After failing to come up a working solution using Backup&Restore utiliy and the time backup, here is what I use for the exact same purpose:

/usr/syno/bin/rsync -ap --delete --verbose /volume1/Dir1/ /volumeUSB1/usbshare/Dir2 >> /tmp/rsyncShared.log 2>&1

In my case I copy a 500GB folder structure from Dir1 folder of one share to Dir2 folder of another share, namely my external usb drive. Procedure is the same in the way you do this between internal shares or internal share to external share. Initially which took me a few hours initially but after that it is only a sync job so it literally takes few seconds at a time. So, it can be run multiple times a day if you need.
I have added the following entry in the crontab: 0 3 * * * root
which would execute the command every day at 3 AM.

I agree with you a such a fundamental function should be readily available in a NAS with this price and quality. After all nobody is obligated to be experienced in Linux. However, if you put in a few hours of effort, you will find out that it is not difficult to setup what you need and you can do a lot more than what's available readily out of the box.
dios1demonio0
I'm New!
I'm New!
Posts: 1
Joined: Sat Aug 12, 2017 6:54 pm

Re: Automatic copy from one folder to another on the same NA

Postby dios1demonio0 » Sat Aug 12, 2017 6:57 pm

gwknight wrote:After failing to come up a working solution using Backup&Restore utiliy and the time backup, here is what I use for the exact same purpose:

/usr/syno/bin/rsync -ap --delete --verbose /volume1/Dir1/ /volumeUSB1/usbshare/Dir2 >> /tmp/rsyncShared.log 2>&1

In my case I copy a 500GB folder structure from Dir1 folder of one share to Dir2 folder of another share, namely my external usb drive. Procedure is the same in the way you do this between internal shares or internal share to external share. Initially which took me a few hours initially but after that it is only a sync job so it literally takes few seconds at a time. So, it can be run multiple times a day if you need.
I have added the following entry in the crontab: 0 3 * * * root
which would execute the command every day at 3 AM.

I agree with you a such a fundamental function should be readily available in a NAS with this price and quality. After all nobody is obligated to be experienced in Linux. However, if you put in a few hours of effort, you will find out that it is not difficult to setup what you need and you can do a lot more than what's available readily out of the box.



Hi I have tried to create the task in my sinology but /usr/syno/bin/rsync is not found, where exactly is rsync? thanks.

Return to “File Station”

Who is online

Users browsing this forum: No registered users and 2 guests