<!--

lxc: linux Container library

(C) Copyright IBM Corp. 2007, 2008

Authors:
Daniel Lezcano <daniel.lezcano at free.fr>
Serge Hallyn <serge.hallyn at ubuntu.com>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

-->

<!DOCTYPE refentry PUBLIC @docdtd@ [

<!ENTITY commonoptions SYSTEM "@builddir@/common_options.sgml">
<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
]>

<refentry>

  <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>

  <refmeta>
    <refentrytitle>lxc-clone</refentrytitle>
    <manvolnum>1</manvolnum>
  </refmeta>

  <refnamediv>
    <refname>lxc-clone</refname>

    <refpurpose>
      clone a new container from an existing one.
    </refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <cmdsynopsis>
      <command>lxc-clone</command>
      <arg choice="opt">-s </arg>
      <arg choice="opt">-K </arg>
      <arg choice="opt">-M </arg>
      <arg choice="opt">-H </arg>
      <arg choice="opt">-B <replaceable>backingstore</replaceable></arg>
      <arg choice="opt">-L <replaceable>fssize</replaceable></arg>
      <arg choice="opt">-p <replaceable>lxcpath</replaceable></arg>
      <arg choice="opt">-P <replaceable>newlxcpath</replaceable></arg>
      <arg choice="opt">-R </arg>
      <arg choice="req">-o <replaceable>orig</replaceable></arg>
      <arg choice="req">-n <replaceable>new</replaceable></arg>
      <arg choice="opt">-- hook arguments</arg>
    </cmdsynopsis>
    <cmdsynopsis>
      <command>lxc-clone</command>
      <arg choice="opt">-s </arg>
      <arg choice="opt">-K </arg>
      <arg choice="opt">-M </arg>
      <arg choice="opt">-H </arg>
      <arg choice="opt">-B <replaceable>backingstore</replaceable></arg>
      <arg choice="opt">-L <replaceable>fssize</replaceable></arg>
      <arg choice="opt">-p <replaceable>lxcpath</replaceable></arg>
      <arg choice="opt">-P <replaceable>newlxcpath</replaceable></arg>
      <arg choice="opt">-R </arg>
      <arg choice="req">orig</arg>
      <arg choice="req">new</arg>
      <arg choice="opt">-- hook arguments</arg>
    </cmdsynopsis>
  </refsynopsisdiv>

  <refsect1>
    <title>Description</title>

    <para>
      <command>lxc-clone</command> Creates a new container as a clone of an existing
      container.  Two types of clones are supported: copy and snapshot.  A copy
      clone copies the root filessytem from the original container to the new.  A
      snapshot filesystem uses the backing store's snapshot functionality to create
      a very small copy-on-write snapshot of the original container.  Snapshot
      clones require the new container backing store to support snapshotting.  Currently
      this includes only aufs, btrfs, lvm, overlayfs and zfs.  LVM devices do not support
      snapshots of snapshots.
    </para>

    <para>
      The backing store of the new container will be the same type as the
      original container, with one exception, overlay containers.
      aufs and overlayfs snapshots can be created of directory backed
      containers.  This can be requested by using (for overlayfs) the
      <replaceable>-B overlayfs</replaceable> arguments.
    </para>

    <para>
      The names of the original and new container can be given (in that order)
      after all options, or can be specified with the
      <replaceable>-o</replaceable> and <replaceable>-n</replaceable> options,
      respectively.
    </para>

  </refsect1>

  <refsect1>

    <title>Options</title>

    <variablelist>

      <varlistentry>
	<term>
	  <option>-s, --snapshot</option>
	</term>
	<listitem>
	  <para>
	    The new container's rootfs will be a snapshot of the original. This option can be specified when the backing store is LVM, btrfs or zfs, and must be specified when you want to snapshot using aufs or overlayfs.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>
	  <option>-K, --keepname</option>
	</term>
	<listitem>
	  <para>
	    Do not change the hostname of the container (in the root
	    filesystem).
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>
	  <option>-M, --keepmac</option>
	</term>
	<listitem>
	  <para>
	    Use the same MAC address as the original container, rather than
	    generating a new random one.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>
	  <option>-H, --copyhooks</option>
	</term>
	<listitem>
	  <para>
	    Copy all mount hooks into the new container's directory, and
	    update any lxcpaths and container names as needed.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>
	  <option>-L, --fssize <replaceable>fssize</replaceable></option>
	</term>
	<listitem>
	  <para>
	    In the case of a block device backed container, a size for the new
	    block device.  By default, the new device will be made the
	    same size as the original.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>
	  <option>-p, --lxcpath <replaceable>lxcpath</replaceable></option>
	</term>
	<listitem>
	  <para>
	    The lxcpath of the original container.  By default, the system
	    wide configured lxcpath will be used.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>
	  <option>-P, --newpath <replaceable>newlxcpath</replaceable></option>
	</term>
	<listitem>
	  <para>
	    The lxcpath for the new container.  By default the same lxcpath
	    as the original will be used.  Note that with btrfs snapshots,
	    changing lxcpaths may not be possible, as subvolume snapshots
	    must be in the same btrfs filesystem.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>
	  <option>-B, --backingstore <replaceable>backingstore</replaceable></option>
	</term>
	<listitem>
	  <para>
	    Select a different backing store for the new container.  By
	    default the same as the original container's is used.  Note that
	    currently changing the backingstore is only supported for
	    aufs and overlayfs snapshots of directory backed containers.  Valid
	    backing stores include dir (directory), aufs, btrfs, lvm, zfs, loop
	    and overlayfs.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>
	  <option>-R, --rename</option>
	</term>
	<listitem>
	  <para>
	    Rename an existing container.
	    <replaceable>orig</replaceable> is renamed <replaceable>new</replaceable>.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>
	  <option>-o, --orig <replaceable>orig</replaceable></option>
	</term>
	<listitem>
	  <para>
	    The name of the original container to clone.
	  </para>
	</listitem>
      </varlistentry>

      <varlistentry>
	<term>
	  <option>-n, --new <replaceable>new</replaceable></option>
	</term>
	<listitem>
	  <para>
	    The name of the new container to create.
	  </para>
	</listitem>
      </varlistentry>


    </variablelist>

  </refsect1>

  <refsect1>
    <title>Clone hook</title>
    <para>
      If the container being cloned has one or more <filename>lxc.hook.clone</filename>
      specified, then the specified hooks will be called for the new container.  The
      first 3 arguments passed to the clone hook will be the container name, a section
      ('lxc'), and the hook type ('clone').  Extra arguments passed
      <command>lxc-clone</command> will be passed to the hook program starting at
      argument 4.  The <filename>LXC_ROOTFS_MOUNT</filename> environment variable gives
      the path under which the container's root filesystem is mounted.  The
      configuration file pathname is stored in <filename>LXC_CONFIG_FILE</filename>, the
      new container name in <filename>LXC_NAME</filename>, the old container name in
      <filename>LXC_SRC_NAME</filename>, and the path or device on which
      the rootfs is located is in <filename>LXC_ROOTFS_PATH</filename>.
    </para>
  </refsect1>

  <refsect1>
    <title>Notes</title>
    <para>
    <command>lxc-clone</command> is deprecated in favor of
    <command>lxc-copy</command>.
    </para>
  </refsect1>

  &seealso;

  <refsect1>
    <title>Author</title>
    <para>Serge Hallyn <email>serge.hallyn@ubuntu.com</email></para>
  </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
