fix: just use filename
This commit is contained in:
@ -150,51 +150,50 @@ Use "--dry-run/-r" to see which secrets and volumes will be moved.`),
|
||||
log.Fatal(i18n.G("failed to create volume %s on %s: %s", v.Name, newServer, err))
|
||||
}
|
||||
|
||||
outgoingFilename := fmt.Sprintf("%s_outgoing.tar.gz", v.Name)
|
||||
log.Debug(i18n.G("creating %s on %s", outgoingFilename, app.Server))
|
||||
tarCmd := fmt.Sprintf("sudo tar --same-owner -czhpf %s -C /var/lib/docker/volumes %s", outgoingFilename, v.Name)
|
||||
filename := fmt.Sprintf("%s_outgoing.tar.gz", v.Name)
|
||||
log.Debug(i18n.G("creating %s on %s", filename, app.Server))
|
||||
tarCmd := fmt.Sprintf("sudo tar --same-owner -czhpf %s -C /var/lib/docker/volumes %s", filename, v.Name)
|
||||
cmd := exec.Command("ssh", app.Server, "-tt", tarCmd)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
log.Fatal(i18n.G("%s failed on %s: output:%s err:%s", tarCmd, app.Server, string(out), err))
|
||||
}
|
||||
|
||||
log.Debug(i18n.G("rsyncing %s from %s to local machine", outgoingFilename, app.Server))
|
||||
cmd = exec.Command("rsync", "-a", "-v", fmt.Sprintf("%s:%s", app.Server, outgoingFilename), outgoingFilename)
|
||||
log.Debug(i18n.G("rsyncing %s from %s to local machine", filename, app.Server))
|
||||
cmd = exec.Command("rsync", "-a", "-v", fmt.Sprintf("%s:%s", app.Server, filename), filename)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
log.Fatal(i18n.G("failed to copy %s from %s to local machine: output:%s err:%s", outgoingFilename, app.Server, string(out), err))
|
||||
log.Fatal(i18n.G("failed to copy %s from %s to local machine: output:%s err:%s", filename, app.Server, string(out), err))
|
||||
}
|
||||
|
||||
incomingFilename := fmt.Sprintf("%s_incoming.tar.gz", v.Name)
|
||||
log.Debug(i18n.G("rsyncing %s (renaming to %s) to %s from local machine", outgoingFilename, incomingFilename, newServer))
|
||||
cmd = exec.Command("rsync", "-a", "-v", outgoingFilename, fmt.Sprintf("%s:%s", newServer, incomingFilename))
|
||||
log.Debug(i18n.G("rsyncing %s to %s from local machine", filename, filename, newServer))
|
||||
cmd = exec.Command("rsync", "-a", "-v", filename, fmt.Sprintf("%s:%s", newServer, filename))
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
log.Fatal(i18n.G("failed to copy %s from local machine to %s: output:%s err:%s", outgoingFilename, newServer, string(out), err))
|
||||
log.Fatal(i18n.G("failed to copy %s from local machine to %s: output:%s err:%s", filename, newServer, string(out), err))
|
||||
}
|
||||
|
||||
log.Debug(i18n.G("extracting %s on %s", incomingFilename, newServer))
|
||||
tarExtractCmd := fmt.Sprintf("sudo tar --same-owner -xzpf %s -C /var/lib/docker/volumes", outgoingFilename)
|
||||
log.Debug(i18n.G("extracting %s on %s", filename, newServer))
|
||||
tarExtractCmd := fmt.Sprintf("sudo tar --same-owner -xzpf %s -C /var/lib/docker/volumes", filename)
|
||||
cmd = exec.Command("ssh", newServer, "-tt", tarExtractCmd)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
log.Fatal(i18n.G("%s failed to extract %s on %s: output:%s err:%s", tarExtractCmd, outgoingFilename, newServer, string(out), err))
|
||||
log.Fatal(i18n.G("%s failed to extract %s on %s: output:%s err:%s", tarExtractCmd, filename, newServer, string(out), err))
|
||||
}
|
||||
|
||||
// Remove tar files
|
||||
log.Debug(i18n.G("removing %s from %s", incomingFilename, newServer))
|
||||
cmd = exec.Command("ssh", newServer, "-tt", fmt.Sprintf("sudo rm %s", incomingFilename))
|
||||
log.Debug(i18n.G("removing %s from %s", filename, newServer))
|
||||
cmd = exec.Command("ssh", newServer, "-tt", fmt.Sprintf("sudo rm %s", filename))
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
log.Fatal(i18n.G("failed to remove %s from %s: output:%s err:%s", incomingFilename, newServer, string(out), err))
|
||||
log.Fatal(i18n.G("failed to remove %s from %s: output:%s err:%s", filename, newServer, string(out), err))
|
||||
}
|
||||
|
||||
log.Debug(i18n.G("removing %s from %s", outgoingFilename, app.Server))
|
||||
cmd = exec.Command("ssh", app.Server, "-tt", fmt.Sprintf("sudo rm %s", outgoingFilename))
|
||||
log.Debug(i18n.G("removing %s from %s", filename, app.Server))
|
||||
cmd = exec.Command("ssh", app.Server, "-tt", fmt.Sprintf("sudo rm %s", filename))
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
log.Fatal(i18n.G("failed to remove %s from %s: output:%s err:%s", outgoingFilename, app.Server, string(out), err))
|
||||
log.Fatal(i18n.G("failed to remove %s from %s: output:%s err:%s", filename, app.Server, string(out), err))
|
||||
}
|
||||
|
||||
log.Debug(i18n.G("removing %s from local machine", outgoingFilename))
|
||||
cmd = exec.Command("rm", outgoingFilename)
|
||||
log.Debug(i18n.G("removing %s from local machine", filename))
|
||||
cmd = exec.Command("rm", filename)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
log.Fatal(i18n.G("failed to remove %s on local machine: output:%s err:%s", outgoingFilename, string(out), err))
|
||||
log.Fatal(i18n.G("failed to remove %s on local machine: output:%s err:%s", filename, string(out), err))
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user