Synology Media Backup Script [download]

Een reactie plaatsen

november 29, 2015 door Tim

[This script is NOT for novice users]
[In any case I can’t be hold responsible for damage or loss of data]

This script is straight forward, but I don’t give any support for getting it to work on any storage or server device.
So you need to know what you are doing.

What do you need to know first:
– good php programming knowledge
– how to configure script variables
If used on the Synology:
– how to run php conjobs on a synology server.
– a good understanding of the synology system and how to configure the it via root.

Everyone takes pictures and movies with his/her smartphone, but what if you want to backup it to a home server?

In my case I use my synology station for this. Everyday the family goes out and takes pictures and movies with their smartphones. When they come home they connect to the home wifi and the phone starts uploading all pictures to their own backup directory on the synology server.

I use the app “SweetHome!” for my android phone (, and set it to synchronize everything and only keep the last three months of media on the phone (= time-window). Like this we keep our phones clean too. Of course there will be similar apps out there who will do the same.

Nevertheless the destination directory is a bulk backup directory for each person and doesn’t make any sense if you want have a nicely organized tree of directories by year/month (eg. /2015-07 – May/ ) .

So what you need to know about the script?
– you run it as a cronjob or by command line; or in my case of the synology you add it to your task scheduler.
– you edit the script and add the name of the person who uploaded the media to his/her backup directory
– you set the source directory of the pictures (eg. /volume1/backup wife)
– you set the destination directory (eg. /volume1/pictures)
– you create a backup directory (eg. /volume1/backup)
– you create a error directory (eg. /volume1/backup/errors)
– you set the time-window to 3 months, or better 4 months, so the files on the phone aren’t uploaded everytime when it syncs to the server.

Here are the config variables you need to configurate:

var $userdir = “wife”; # user who takes the pictures
var $delete_source_after = “4 months”; # deletes files in the bulk directory after … X months (and moves them to $bck)
var $src = “/volume1/backup wife”; # source directory (bulk directory of media)
var $dst = “/volume1/pictures”; # root directory of destination directory
var $bck = “/volume1/backup”; # dir for archiving before deletion
var $err = “/volume1/backup/errors”; # dir for storing files with different MD5’s
var $lgs = “/volume1/crons”; # dir for logs

note: for the backup directory you can also choose an external drive that you connect to your server/synology.
note2: for each user you need to create a new copyto.php file with the name of the user who uploads media.

Synology Media Backup Script Download
Here you go – V0.1 – :


Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen. logo

Je reageert onder je account. Log uit /  Bijwerken )

Google photo

Je reageert onder je Google account. Log uit /  Bijwerken )


Je reageert onder je Twitter account. Log uit /  Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit /  Bijwerken )

Verbinden met %s

Deze site gebruikt Akismet om spam te bestrijden. Ontdek hoe de data van je reactie verwerkt wordt.


november 2015

Blog Stats

  • 228.387 hits
%d bloggers liken dit: