I've had Kubuntu on my desktop for a few months now, but I'm planning to install it on my new netbook (as soon as the damn thing ships). I'd really like to be able to automatically sync my most-used document folders across both machines -- ideally it would be wireless and in the background, but a USB stick that I plug into one and then the other would work too, I suppose. I would greatly appreciate suggestions for a utility that could manage this without too much headache.
Announcement
Collapse
No announcement yet.
Automatic folder sync across machines?
Collapse
This topic is closed.
X
X
-
Re: Automatic folder sync across machines?
You can also use CLI tool rsync (which is in my opinion the best tool for the job), it can sync directories over network (via ssh) on different hosts. You could create a sync script that you can run manually (sync now), or scheduled via cron.
If you like GUI way of doing things, there are a few GUI front-ends for rsync, luckybackup is one (and available from the repos).
- Top
- Bottom
Comment
-
-
Re: Automatic folder sync across machines?
Originally posted by aristCheck out this thread.
Of course, if one wants network shares for other things as well (media/file server etc.), setting up NFS is a good idea (I'd still do any syncing with rsync).
- Top
- Bottom
Comment
-
Re: Automatic folder sync across machines?
Any way to get rsynch to preserve ownership and permissions and file date/times and only update new or newer files?
I tried it for a while (admittedly short) and went back to cp because rsynch insisted on stamping all files with the current date/time and messing with ownership and copying everything over every time. I really didn't want to spend hours and hours reading and understanding the rsynch documentation (it seemed to me that the writer assumed that I didn't really need the documentation, but that is probably just me being my usual dense self ) and experimenting with options and path specs to get things just right. The cp options were just so much easier to fathom. In under 15 minutes I had a cp script working, copying the proper files and preserving ownership and date/time stamps.
- Top
- Bottom
Comment
-
Re: Automatic folder sync across machines?
Originally posted by geezerAny way to get rsynch to preserve ownership and permissions and file date/times and only update new or newer files?
I tried it for a while (admittedly short) and went back to cp because rsynch insisted on stamping all files with the current date/time and messing with ownership and copying everything over every time. I really didn't want to spend hours and hours reading and understanding the rsynch documentation (it seemed to me that the writer assumed that I didn't really need the documentation, but that is probably just me being my usual dense self ) and experimenting with options and path specs to get things just right. The cp options were just so much easier to fathom. In under 15 minutes I had a cp script working, copying the proper files and preserving ownership and date/time stamps.
Quick edit. Hoping that it might do some people some good. Here is the script that I wrote to do daily snapshots on my home directory (as well as my wife's and my music server). I've been running it about 6 months (since I got my NAS) and it works great.
Code:#!/bin/bash # Derived from [url]http://www.mikerubel.org/computers/rsync_snapshots/[/url] unset PATH # Command Locations ECHO=/bin/echo RM=/bin/rm MV=/bin/mv CP=/bin/cp TOUCH=/bin/touch MOUNT=/bin/mount GREP=/bin/grep WC=/usr/bin/wc RSYNC=/usr/bin/rsync DATE=/bin/date # File Locations SNAPSHOT_DIR=/media/backup SNAPSHOT_MAX=7 SNAPSHOT_FILE=snapshot BACKUP_DIR=/home/tnorris RSYNC_DEST=tnorris@192.168.1.6::tnorrisbackup EXCLUDES=/home/tnorris/.exclude PASSWORD_FILE=/home/tnorris/.rsync_pw log_info () { $ECHO "`$DATE` - $1" } log_error () { $ECHO "`$DATE` - $1" >&2 } log_info "Starting snapshot" # Check if BACKUP_DIR is mounted if [ `$MOUNT | $GREP "$SNAPSHOT_DIR" | $WC -l` -eq 0 ]; then log_error "Exiting. Snapshot Directory is not mounted." exit fi # Delete the oldest snapshot, if it exists: if [ -d $SNAPSHOT_DIR/$SNAPSHOT_FILE.$(($SNAPSHOT_MAX-1)) ]; then $RM -rf $SNAPSHOT_DIR/$SNAPSHOT_FILE.$(($SNAPSHOT_MAX-1)) status=$? if [ $status -eq 0 ] then log_info "Removed $SNAPSHOT_DIR/$SNAPSHOT_FILE.$(($SNAPSHOT_MAX-1))" else log_error "Removal of $SNAPSHOT_DIR/$SNAPSHOT_FILE.$(($SNAPSHOT_MAX-1)) failed." exit $status fi fi # Shift each snapshot back one for ((i=($SNAPSHOT_MAX-2); i>=0; i--)) do FROM=$i TO=$(($i+1)) if [ -d $SNAPSHOT_DIR/$SNAPSHOT_FILE.$FROM ]; then $MV $SNAPSHOT_DIR/$SNAPSHOT_FILE.$FROM $SNAPSHOT_DIR/$SNAPSHOT_FILE.$TO status=$? if [ $status -eq 0 ] then log_info "Moved $SNAPSHOT_DIR/$SNAPSHOT_FILE.$FROM to $SNAPSHOT_DIR/$SNAPSHOT_FILE.$TO" else log_error "Move of $SNAPSHOT_DIR/$SNAPSHOT_FILE.$FROM to $SNAPSHOT_DIR/$SNAPSHOT_FILE.$TO failed." exit $status fi fi done # rsync from the $BACKUP_DIR into the most recent snapshot $RSYNC -a --stats --delete --delete-excluded --exclude-from="$EXCLUDES" --link-dest=../$SNAPSHOT_FILE.1 --password-file="$PASSWORD_FILE" "$BACKUP_DIR/" "$RSYNC_DEST"/$SNAPSHOT_FILE.0 status=$? if [ $status -eq 0 ] then log_info "Rsynced $BACKUP_DIR/ to $RSYNC_DEST/$SNAPSHOT_FILE.0 linked to ../$SNAPSHOT_FILE.1" else log_error "Rsync of $BACKUP_DIR/ to $RSYNC_DEST/$SNAPSHOT_FILE.0 linked to ../$SNAPSHOT_FILE.1 failed." exit $status fi # Update the mtime of $SNAPSHOT_FILE.0 to reflect the snapshot time $TOUCH $SNAPSHOT_DIR/$SNAPSHOT_FILE.0 status=$? if [ $status -eq 0 ] then log_info "Touched $SNAPSHOT_DIR/$SNAPSHOT_FILE.0" else log_error "Touch of $SNAPSHOT_DIR/$SNAPSHOT_FILE.0 failed." exit $status fi log_info "Snapshot Complete"
- Top
- Bottom
Comment
-
Re: Automatic folder sync across machines?
Originally posted by geezerAny way to get rsynch to preserve ownership and permissions and file date/times and only update new or newer files?
from "man rsync":
-u, --update
This forces rsync to skip any files which exist on the destination and have a modified time that is newer than the source file. (If an existing destination file has a modification time equal to the source file's, it will be updated if the sizes are different.)
Note that this does not affect the copying of symlinks or other special files. Also, a difference of file format between the sender and receiver is always considered to be important enough for an update, no matter what date is on the objects. In other words, if the source has a directory where the destination has a file, the transfer would occur regardless of the timestamps.
This option is a transfer rule, not an exclude, so it doesn't affect the data that goes into the file-lists, and thus it doesn't affect deletions. It just limits the files that the receiver requests to be transferred.
- Top
- Bottom
Comment
Comment