# lxc-copy

## NAME



           lxc-copy - copy an existing container.
    


## SYNOPSIS



           **lxc-copy**{-n, --name _name_} [-P, --lxcpath _path_] {-N, --newname
                    _newname_} [-p, --newpath _newpath_] [-B, --backingstorage
                    _backingstorage_] [-s, --snapshot] [-a, --allowrunning]
                    [-K, --keepname] [-D, --keepdata] [-M, --keepmac] [-L,
                    --fssize _size [unit]_] [-- hook arguments]
           **lxc-copy**{-n, --name _name_} [-P, --lxcpath _path_] [-N, --newname
                    _newname_] [-p, --newpath _newpath_] {-e, --ephemeral} [-B,
                    --backingstorage _backingstorage_] [-s, --snapshot] [-a,
                    --allowrunning] [-K, --keepname] [-D, --keepdata] [-M,
                    --keepmac] [-L, --fssize _size [unit]_] [-- hook arguments]
           **lxc-copy**{-n, --name _name_} [-P, --lxcpath _path_] [-N, --newname
                    _newname_] [-p, --newpath _newpath_] {-e, --ephemeral} [-B,
                    --backingstorage _backingstorage_] [-s, --snapshot] [-t,
                    --tmpfs] [-K, --keepname] [-M, --keepmac] [-- hook
                    arguments]
           **lxc-copy**{-n, --name _name_} [-P, --lxcpath _path_] {-N, --newname
                    _newname_} [-p, --newpath _newpath_] {-R, --rename}
    


## DESCRIPTION



           **lxc-copy** creates and optionally starts (ephemeral or non-ephemer‐
           al) copies of existing containers.
    
           **lxc-copy** creates copies of existing containers. Copies can be com‐
           plete clones of the original container. In  this  case  the  whole
           root  filesystem of the container is simply copied to the new con‐
           tainer. Or they can be snapshots, i.e. small copy-on-write  copies
           of  the  original  container.  In  this case the specified backing
           storage for the copy must support snapshots.  This  currently  in‐
           cludes  btrfs,  lvm (lvm devices do not support snapshots of snap‐
           shots.), overlay, and zfs.
    
           The copy's backing storage will be of the same type as the  origi‐
           nal  container.  overlay  snapshots of directory backed containers
           are exempted from this rule.
    
           When the _-e_ flag is specified an ephemeral snapshot of the  origi‐
           nal  container  is  created and started. Ephemeral containers will
           have **lxc.ephemeral = 1** set in their config file and  will  be  de‐
           stroyed on shutdown. When _-e_ is used in combination with _-D_ a non-
           ephemeral snapshot of the original container is created and start‐
           ed.   Ephemeral  containers  can also be placed on a tmpfs with _-t_
           flag. NOTE: If an ephemeral container that is placed on a tmpfs is
           rebooted all changes made to it will currently be lost!
    
           When _-e_ is specified and no newname is given via _-N_ a random  name
           for the snapshot will be chosen.
    
           Containers  created  and  started  with _-e_ can have custom mounts.
           These are specified with the  _-m_  flag.  Currently  two  types  of
           mounts are supported: _bind_ , and _overlay_. Mount types are specified
           as  suboptions  to the _-m_ flag and can be specified multiple times
           separated by commas. _overlay_ mounts are currently specified in the
           format _-m overlay=/src:/dest_. When no destination _dest_  is  speci‐
           fied  _dest_  will  be  identical  to _src_. Read-only _bind_ mounts are
           specified _-m bind=/src:/dest:ro_  and  read-write  _bind_  mounts  _-m_
           _bind=/src:/dest:rw_.  Read-write _bind_ mounts are the default and _rw_
           can be missing when a read-write mount is  wanted.  When  _dest_  is
           missing  _dest_  will  be  identical to _src_. An example for multiple
           mounts  would   be   _-m_   _bind=/src1:/dest1:ro,bind=/src2:ro,over‐_
           _lay=/src3:/dest3_.
    
           The  mounts,  their options, and formats supported via the _-m_ flag
           are subject to change.
    


## OPTIONS



           **-N,--newname** _newname_
                  The name for the copy.
    
           **-p,--newpath** _newpath_
                  The path for the copy.
    
           **-R,--rename**
                  Rename the original container.
    
           **-s,--snapshot**
                  Create a snapshot of the original container. The backing
                  storage for the copy must support snapshots. This currently
                  includes btrfs, lvm, overlay, and zfs.
    
           **-a,--allowrunning**
                  Allow the creation of a Snapshot of an already running con‐
                  tainer.  This may cause data corruption or data loss de‐
                  pending on the used filesystem and applications. Use with
                  care.
    
           **-F,--foreground**
                  Run the snapshot in the foreground. The snapshots console
                  will be attached to the current tty. (This option can only
                  be specified in conjunction with _-e_.)
    
           **-d, --daemon**
                  Run the snapshot as a daemon (This is the default mode for
                  ephemeral containers.). As the container has no more tty,
                  if an error occurs nothing will be displayed, the log file
                  can be used to check the error. (This option can only be
                  specified in conjunction with _-e_.)
    
           **-m, --mount** _mounttype_
                  Specify a mount for a snapshot The _opts_ argument for the
                  mount type can by of type {bind, overlay}. For example **-m**
                  **bind=/src:/dest:ro,overlay=/src:/dest**(This option can cur‐
                  rently only be specified in conjunction with _-e_.).
    
           **-t, --tmpfs**
                  When this option is specified the ephemeral container will
                  be placed on a tmpfs. NOTE: Rebooting an ephemeral contain‐
                  er that is located on a tmpfs will currently cause all
                  changes made to it to be lost. This flag will only work for
                  ephemeral containers created with the _-e_ flag. The original
                  container, from which the ephemeral snapshot is created,
                  must be stored as a simple directory.
    
           **-B, --backingstorage** _backingstorage_
                  Specify the backing storage type to be used for the copy
                  where 'backingstorage' is of type 'btrfs', 'dir', 'lvm',
                  'loop', 'overlay', or 'zfs'.
    
           **-L, --fssize** _size [unit]_
                  Specify the size for an 'lvm' filesystem.
    
           **-K, --keepname**
                  When this option is specified the hostname of the original
                  container will be kept for the copy.
    
           **-D, --keepdata**
                  When this option is specified with _-e_ a non-ephemeral con‐
                  tainer is created and started.
    
           **-M, --keepmac**
                  When this option is specified the MAC address of the origi‐
                  nal container will be kept for the copy.
    


## COPY HOOK



           If the container being copied has one or more _lxc.hook.clone_ spec‐
           ified, then the specified hooks will be called for the new con‐
           tainer. 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 to **lxc-copy** will be passed to the hook pro‐
           gram starting at argument 4. The _LXC_ROOTFS_MOUNT_ environment
           variable gives the path under which the container's root filesys‐
           tem is mounted. The configuration file pathname is stored in
           _LXC_CONFIG_FILE_ , the new container name in _LXC_NAME_ , the old con‐
           tainer name in _LXC_SRC_NAME_ , and the path or device on which the
           rootfs is located is in _LXC_ROOTFS_PATH_.
    


## COMMON OPTIONS



           These options are common to most of lxc commands.
    
           **-?, -h, --help**
                  Print a longer usage message than normal.
    
           **--usage**
                  Give the usage message
    
           **-q, --quiet**
                  mute on
    
           **-P, --lxcpath=**_PATH_
                  Use an alternate container path. The default is
                  /var/lib/lxc.
    
           **-o, --logfile=**_FILE_
                  Output to an alternate log _FILE_. The default is no log.
    
           **-l, --logpriority=**_LEVEL_
                  Set log priority to _LEVEL_. The default log priority is ER‐
                  ROR. Possible values are : FATAL, ALERT, CRIT, WARN, ERROR,
                  NOTICE, INFO, DEBUG, TRACE.
    
                  Note that this option is setting the priority of the events
                  log in the alternate log file. It do not have effect on the
                  ERROR events log on stderr.
    
           **-n, --name=**_NAME_
                  Use container identifier _NAME_.  The container identifier
                  format is an alphanumeric string.
    
           **--rcfile=**_FILE_
                  Specify the configuration file to configure the virtualiza‐
                  tion and isolation functionalities for the container.
    
                  This configuration file if present will be used even if
                  there is already a configuration file present in the previ‐
                  ously created container (via lxc-create).
    
           **--version**
                  Show the version number.
    


* * *