Keep Remote Directory Up-to-date
How "real-time" do you want the syncing? I would still lean toward rsync since you know it is going to be fully supported on both platforms (Windows, too, with cygwin) and you can run it via a cron job. I have a super-simple bash file that I run on my system (this does not remove old files):
#!/bin/sh
rsync -avrz --progress --exclude-from .rsync_exclude_remote . remote_login@remote_computer:remote_dir
# options
# -a archive
# -v verbose
# -r recursive
# -z compress
Your best bet is to set it up and try it out. The -n (--dry-run)
option is your friend!
Keep in mind that rsync (at least in cygwin) does not support unicode file names (as of 16 Aug 2008).
Winscp Keep remote directory up to date save custom Synchronize options as default
There's Use same options next time checkbox below.
WinSCP Keep Remote Directory Up To Date only synchronizes files once a minute
Unfortunately it's a limitation of how WinScp determines a file is updated, and the timestamp granularity that FTP provides. If possible, connect with SFTP which will provide second granularity.
Keep remote directory up to date using git
Create a hook in .git/hooks
called post-receive
. The file should contain the following...
#!/bin/sh
GIT_WORK_TREE=/path/to/where/you/want/working/files git checkout -f
I had some problems trying to get this to work with a git repo that wasn't --bare
(use git init --bare
when setting up, then put the working directory somewhere else)
example:
mkdir yourbarerepo.git
cd yourbarerepo.git
git init --bare
cd hooks
touch post-receive
nano post-recieve
#paste in contents above
#make sure the path where you want the working files to go is already created
Synchronizing today's files from remote to local directory using WinSCP
Use a file mask with a time constraint and today
keyword:
synchronize local -filemask=">=today" "D:\ftp\OUT" /out
This syntax is supported by WinSCP 5.15 and newer only.
In earlier versions of WinSCP, you can use the %TIMESTAMP%
syntax to create the today's constraint.
synchronize local -filemask=">=%TIMESTAMP#yyyy-mm-dd%" "D:\ftp\OUT" /out
Further reading:
- Question WinSCP time based file download;
- WinSCP article on Downloading the most recent file.
Keeping FTP Folder Constantly Up To Date Based On Local Folder
I am interested in this as well. I know about the Rsync option of course, but would like to have a Windows option that does the same thing..
Can I use git to keep a remote server up to date?
You have in this blog post an example of Git repo used for staging:
IDE => local Git repository => remote bare Git repository
=> Git repository with the live web application
It involves a post-update hook on the bare repo side, in order to trigger the update of the repo on the live web server side.
The final step is to define the “post-update” hook script on the bare repository, which is called when the bare repository receives data.
To enable the “post-update” hook, we have to either makehooks/post-update
executable or renamehooks/post-update.sample
tohooks/post-update
, depending on the Git version.
In this script, we simply change to the folder of the live application, and start the pull operation:
#!/bin/sh
cd $HOME/example.org
unset GIT_DIR
git pull bare master
exec git-update-server-info
The reason there is a bare remote repo is because it is “discouraged” to do a push into a repo with a working directory.
Related Topics
Serial Port Doesn't Work Properly After Reboot, Unless I Execute Minicom
Prompting for User Input in Assembly Ci20 Seg Fault
Difference Between Cgroups and Namespaces
How to Edit a Binary File on Unix Systems
How to Use Nohup to Run Process as a Background Process in Linux
Getting Stacktrace from Core Dump
How to Load Luks Passphrase from Usb, Falling Back to Keyboard
Setting Node_Env for Node.Js + Expressjs Application as a Daemon Under Ubuntu
How to Get the Variable Value Inside the Eof Tags
Black Color Showing on Cmy Channels When Converted to Cmyk Using Ghostscript
How to Install Cargo on a Rhel Linux Server
Dd: How to Calculate Optimal Blocksize
Linux Kernel "Historical" Git Repository with Full History
Internals of a Linux System Call
Linux, Why Can't I Write Even Though I Have Group Permissions