Mirror directory with mirrordir command

rsyn is the best tool for mirroring servers and data. However, there is also mirrordir tool. As name suggest it can mirror directories and do lots of other things. It offers lots of options for die hard shell scripting fans. It can copy, mirror directory trees via a minimal set of changes, locally or over FTP, or over a secure tcp connection.

From the man page:

mirrordir copies files that are different between the directories control and mirror to the directory mirror. Files whose modification times or sizes differ are copied. File permissions, ownerships, modification times, access times (only if –access-times is used), sticky bits, and device types are duplicated. Symlinks are duplicated without any translation. Symlink modification and access times (of the symlink itself, not the file it points to) are not preserved. Hard linked files are merely copied.

mirrordir command supports strong stream cipher encryption and Diffie-Hellman key exchanges with several possible key sizes.

Install mirrordir

Use apt-get or ports system command:
$ sudo apt-get install mirrordir

mirrordir examples

Mirror ~/scripts to ~/scripts.backup:
$ mkdir ~/scripts.backup
$ mirrordir -v ~/scripts ~/scripts.backup

If you rerun mirrordir again, only the updated files are copied.

You can mirroring FTP sites:
$ mirrordir -v ftp://ftp.nixcraft.in/pub /home/backup/nixcraft.in/ftp/pub

mirrordir offers tons of option, refer mirrordir man page for more examples and options:
$ man mirrordir


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 5 comments so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
5 comments… add one
  • JF Nov 29, 2007 @ 14:06

    I am not sure I understand why I should use this over rsync?

  • 🐧 nixCraft Nov 29, 2007 @ 14:23

    JF,

    No need to make a switch. As I said earlier, rsync is the best. However, this is another tool with some additional options for die hard shell scripting fan.

  • letsnurture Aug 4, 2009 @ 20:50

    Hi,

    Anybody knows that how can I reference multiple subdomains to same directory in linux? Yeah, I know that if I use virtual hosts and they all point to one common folder. Is there any other way to do so? i.e. I have a,b,c,d sub domains(basically directory) and then I run one website say ‘x'(source code) under ‘a’. Is that possible to use ‘x’ source code for sub-domains b,c,d without copying it? I mean in linux, there is symlink concept but dont know exactly.

    Thanks in advance,
    Web-Farmer,

  • alex Jun 12, 2010 @ 21:39

    no body knows a real time FS clonning tool ?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum