mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-11-06 05:17:08 +00:00
The etcd data dir is backed up with "cp -r <dataDir> <backupDir>" into an existing backup dir, so the data lives in <backupDir>/<basename>. Rolling back with "cp -r <backupDir> <dataDir>" copied the backup dir inside the data dir and left the live data untouched. Replace the cp and xcopy variants of CopyDir with one portable Go implementation that copies the contents of src and keeps the source file modes. Remove the member dir before restoring so files written since the backup do not survive, and refuse to clear it at all unless the backup has a member dir to restore from. The backup copies the data dir of a running etcd, so it can fail when etcd renames a WAL file during the copy. Retry it for up to 30 seconds, starting from an empty backup dir each time.