How to checkpoint and restore a Linux process (using criu)

Checkpoint/Restore In Userspace – CRIU/CRIU@wiki is a tool to freeze a running application (or part of it) and checkpoint it to persistent storage as a collection of files. One can then use the files to restore and run the application from the point it was frozen at. Needs Linux kernel 3.9.

# install from binary, for debian/ubuntu
$ (debian/ubuntu) sudo apt-get install libprotobuf-dev libprotoc-dev protobuf-c-compiler libprotobuf-c0 libprotobuf-c0-dev
$ wget http://download.openvz.org/criu/criu-1.3.1.tar.bz2 -O - | tar -xj
$ make -C crtools-1.3.1

# install from srpm, for el/centos
$ sudo yum install protobuf-c-devel --enablerepo=epel
$ rpmbuild --rebuild http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/source/SRPMS/c/criu-1.3.1-1.fc22.src.rpm
$ rpm -Uv criu*.rpm

# dump, checkpoint a running process; process will terminate and its state will be stored in set of files in current directory
$ criu dump -t <PID>

# restore a dumped process to its original running state
$ criu restore -t <PID>

# if process launched from shell use '--shell-job'
$ criu dump -t <PID> --shell-job
$ criu restore -t <PID> --shell-job

# to re-parent restored process to init, use 'restore-detached'
$ criu restore -t <PID> --shell-job --restore-detached

# to checkpoint and restore a process w/ active TCP connections, use '--tcp-established'; uses http://lwn.net/Articles/495304/
$ criu dump -t <PID> --tcp-established
$ criu restore -t <PID> --tcp-established

# live migration application or container between machines, see http://criu.org/Live_migration
$ criu dump --tree <pid> --images-dir <path-to-existing-directory> --leave-stopped
$ scp -r <path-to-images-dir> <dst>:/<path-to-images>
$ criu restore --tree <pid> --images-dir <path-to-images>

from How to checkpoint and restore a Linux process

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s