bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

can you please add a synchronization feature to the GNU cp


From: William Tambe
Subject: can you please add a synchronization feature to the GNU cp
Date: Wed, 11 Jun 2008 11:34:59 -0500
User-agent: Thunderbird 2.0.0.14 (X11/20080421)

Hi,
Can you please add a synchronization feature to the GNU cp so that files
not found in the source files/folders get removed from the destination
folder?

This is a very useful feature for backups without having to use very
expensive routines.

I know rsync provide a similar feature but it would be nice to have just a single option to the cp command to do the work without having to use another tool which has its own set of options and feature.

It would make the cp command much more complete.

To clarify what I mean, here below is a small bash script that I use to
backup my machine on an external drive. I would need such a long script
if a synchronization feature was added to the GNU cp.

#! /bin/sh

destdir='/mnt/.disk_backup'

[ $UID -eq 0 -a -d ${destdir} ] && {
        cd /
        echo 'backing up...'

        # It is awsome that cp does not abrutly failed when there is no
        # space left on the device holding ${destdir} this way we can
        # still copy file with size small enough to fit inside the backup
        # device, untill it gets really full.
        cp -axuv /{bin,boot,etc,home,lib,opt,sbin,usr,var,win} ${destdir}
        echo 'syncronizing...'
        cd ${destdir} || {
                # it very important to move to ${destdir}
                # otherwise we would be deleting all the files
                # on the system. Because find below get a list of
                # files with respect to the current working directory.
                # I almost lost all my files.
                echo "cd ${destdir} failed"
                exit 1
        }

        find . | while read file
        do
                [ -e "/${file}" -o -L "/${file}" ] || rm -vrf ${file}
        done
        echo 'done'
} || echo 'backup error'




reply via email to

[Prev in Thread] Current Thread [Next in Thread]