Warning: this code is provided on a best effort basis and is not in any way officially supported or sanctioned by Cohesity. The code is intentionally kept simple to retain value as example code. The code in this repository is provided as-is and the author accepts no liability for damages resulting from its use.
This Python script enumerates the files that are available for restore from the specified server/job. The file list is written to stdout as JSON.
Run these commands from a terminal to download the script(s) into your current directory
# Begin download commands
curl -O https://raw.githubusercontent.com/cohesity/community-automation-samples/main/python/backedUpFileListJSON/backedUpFileListJSON.py
curl -O https://raw.githubusercontent.com/cohesity/community-automation-samples/main/python/pyhesity.py
chmod +x backedUpFileListJSON.py
# End download commands- backedUpFileListJSON.py: the main python script
- pyhesity.py: the Cohesity REST API helper module
Place all files in a folder together. then, run the main script like so:
To list what versions are available:
./backedUpFileListJSON.py -v mycluster \
-u myuser \
-d mydomain.net \
-s server1.mydomain.net \
-j 'My Backup Job' \
-lTo use a specific job run ID:
./backedUpFileListJSON.py -v mycluster \
-u myuser \
-d mydomain.net \
-s server1.mydomain.net \
-j 'My Backup Job' \
-r 123456To choose the backup at or after the specified file date:
./backedUpFileListJSON.py -v mycluster \
-u myuser \
-d mydomain.net \
-s server1.mydomain.net \
-j 'My Backup Job' \
-f '2020-06-30 13:00:00'- -v, --vip: (optional) DNS or IP of the Cohesity cluster to connect to (default is helios.cohesity.com)
- -u, --username: (optional) username to authenticate to Cohesity cluster (default is helios)
- -d, --domain: (optional) domain of username (defaults to local)
- -i, --useApiKey: (optional) use API key for authentication
- -pwd, --password: (optional) password or API key
- -np, --noprompt: (optional) do not prompt for password
- -mcm, --mcm: (optional) connect through MCM
- -c, --clustername: (optional) helios/mcm cluster to connect to
- -m, --mfacode: (optional) MFA code for authentication
- -s, --sourceserver: name of server to inspect (repeat for multiple)
- -j, --jobname: name of protection job to run
- -l, --showversions: (optional) show available versions
- -t, --start: (optional) filter on versions after date
- -e, --end: (optional) filter on versions before date
- -r, --runid: (optional) use specific run ID
- -f, --filedate: (optional) date to inspect (next backup after date will be inspected)
- -p, --startpath: (optional) start listing files at path (default is /)
- -n, --noindex: (optional) do not use the index (otherwise index usage will be automatic)
- -x, --forceindex: (optional) force use the index (otherwise index usage will be automatic)
- -nt, --newerthan: (optional) show files added/modified in the last X days
- -ext, --extension: (optional) only show files that end with the specified extension
- -f2, --format2: (optional) alternate JSON output format