etcd2-restore.service 1020 B

1234567891011121314151617181920212223242526
  1. [Unit]
  2. Description=Restore single-node etcd2 node from rclone endpoint
  3. Conflicts=etcd2.service etcd2-backup.service
  4. Before=etcd2.service etcd2-backup.service
  5. [Service]
  6. Type=oneshot
  7. ExecStartPre=/usr/bin/rm -rf ${ETCD_DATA_DIR}/member
  8. ExecStartPre=/usr/bin/mkdir -p ${ETCD_RESTORE_DIR}
  9. ExecStartPre=/usr/bin/rm -rf ${ETCD_RESTORE_DIR}/member
  10. # Copy the last backup from rclone endpoint
  11. ExecStartPre=/usr/bin/docker run --rm \
  12. -v ${RCLONE_CONFIG_PATH}:/etc/rclone.conf \
  13. -v ${ETCD_RESTORE_DIR}:/etcd2backup \
  14. quay.io/coreos/rclone:latest \
  15. --config /etc/rclone.conf --checksum=${RCLONE_CHECKSUM} \
  16. copy ${RCLONE_ENDPOINT}/%m /etcd2backup
  17. ExecStartPre=/usr/bin/ls -R ${ETCD_RESTORE_DIR}
  18. ExecStartPre=/opt/bin/etcd2-restore -etcd-name ${ETCD_NAME} -etcd-peer-urls ${ETCD_INITIAL_ADVERTISE_PEER_URLS}
  19. ExecStartPre=/usr/bin/cp -r ${ETCD_RESTORE_DIR}/member ${ETCD_DATA_DIR}/member
  20. ExecStart=/usr/bin/chown -R etcd:etcd ${ETCD_DATA_DIR}/member
  21. [Install]
  22. WantedBy=multi-user.target