Copying files#

List of files#

Locally#

  1. List the files that you would like to have copied. For example:

    cd /path/to/your/files
    shelephant_dump *.h5
    

    This creates a file shelephant_dump.yaml with a list of files:

    - file1.h5
    - file2.h5
    - file3.h5
    

    Note

    The filenames are relative to shelephant_dump.yaml.

  2. Copy all files to some destination:

    shelephant_cp shelephant_dump.yaml /path/to/destination
    

    This copies:

    file1.h5 -> /path/to/destination/file1.h5
    file2.h5 -> /path/to/destination/file2.h5
    file3.h5 -> /path/to/destination/file3.h5
    

    Note

    A copy plan is proposed before copying files. Copying only proceeds if the plan is accepted. This plan is based on precomputed sha256 checksums, rsync criteria, and/or simple file existence. Based on the available information and backend a default combination is used, but this can be customised. Important: files that are listed as equal are not touched in any way.

To SSH host#

  1. List the files that you would like to have copied. For example:

    cd /path/to/your/files
    shelephant_dump *.h5
    

    This creates a file shelephant_dump.yaml with a list of files (see above).

  2. Copy to your remote host:

    shelephant_cp shelephant_dump.yaml /path/on/host --ssh user@host
    

    Note

    rsync is used to propose a copy plan and to copy files if that plan is accepted. In this case rsync is a mandatory dependency.

    Tip

    You can store the host information by:

    shelephant_hostinfo /path/on/host --ssh user@host
    

    and then copy files by:

    shelephant_cp shelephant_dump.yaml shelephant_hostinfo.yaml
    

From SSH host#

  1. List the files that you would like to have copied on the host. For example:

    ssh user@host
    cd /path/on/host
    shelephant_dump *.h5
    

    This creates a file shelephant_dump.yaml with a list of files (see above).

  2. Copy from the remote host on your local machine:

    cd /path/to/copied/files
    shelephant_hostinfo /path/on/destination --ssh user@host -d
    shelephant_cp shelephant_hostinfo.yaml .
    

Watch directory#

Suppose that you have a data container in

/path/to/your/files

and you would like to keep a backup of certain files (e.g. *.h5) in

/path/to/backup
  1. Create a file containerinfo.yaml in /path/to/backup with the following content:

    root: /path/to/your/files  # may be relative
    search:
        - rglob: '*.h5'
    
  2. Get updates from that source:

    shelephant_hostinfo -iu containerinfo.yaml
    

    Tip

    -i computes the sha256 checksums, which may not be needed depending on you use.

    Note

    Run this command (and the command below) from /path/to/backup.

  3. Update the ‘backup’:

    shelephant_cp containerinfo.yaml .
    

    Note

    This will show a copy plan and ask for confirmation.

    Tip

    To compare files based on their sha256 checksums, for example create in /path/to/backup a file localinfo.yaml with the following content:

    root: "."
    search:
        - rglob: '*.h5'
    

    and then run:

    shelephant_hostinfo -iu localinfo.yaml
    

    To copy now use:

    shelephant_diff containerinfo.yaml localinfo.yaml
    

    (You can also use shelephant_cp to copy. In that case the copy-plan can be based purely on sha256.)