volumes: Add support for exporting volumes to external tar

Adds support for transferring data between systems and backing up systems.
Use cases: recover from disasters or move data between machines.

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
This commit is contained in:
flouthoc
2021-08-20 14:22:54 +05:30
parent 30b036c5d3
commit edddfe8c4f
10 changed files with 200 additions and 0 deletions

View File

@ -139,6 +139,17 @@ func (v *Volume) MountPoint() (string, error) {
return v.mountPoint(), nil
}
// MountCount returns the volume's mountcount on the host from state
// Useful in determining if volume is using plugin or a filesystem mount and its mount
func (v *Volume) MountCount() (uint, error) {
v.lock.Lock()
defer v.lock.Unlock()
if err := v.update(); err != nil {
return 0, err
}
return v.state.MountCount, nil
}
// Internal-only helper for volume mountpoint
func (v *Volume) mountPoint() string {
if v.UsesVolumeDriver() {