Skip to content

Commit 64846b5

Browse files
committed
Remover export/import eth1 data cmds
1 parent cbacb85 commit 64846b5

File tree

3 files changed

+0
-287
lines changed

3 files changed

+0
-287
lines changed

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ The following commands are available via the Smartnode client:
133133
- `rocketpool service install-update-tracker, d` - Install the update tracker that provides the available system update count to the metrics dashboard
134134
- `rocketpool service check-cpu-features, ccf` - Checks if your CPU supports all of the features required by the "modern" version of certain client images. If not, it prints what features are missing.
135135
- `rocketpool service get-config-yaml` - Generate YAML that shows the current configuration schema, including all of the parameters and their descriptions
136-
- `rocketpool service export-eth1-data` - Exports the execution client (eth1) chain data to an external folder. Use this if you want to back up your chain data before switching execution clients.
137-
- `rocketpool service import-eth1-data` - Imports execution client (eth1) chain data from an external folder. Use this if you want to restore the data from an execution client that you previously backed up.
138136
- `rocketpool service resync-eth1` - Deletes the main ETH1 client's chain data and resyncs it from scratch. Only use this as a last resort!
139137
- `rocketpool service resync-eth2` - Deletes the ETH2 client's chain data and resyncs it from scratch. Only use this as a last resort!
140138
- `rocketpool service terminate, t` - Deletes all of the Rocket Pool Docker containers and volumes, including your ETH1 and ETH2 chain data and your Prometheus database (if metrics are enabled). Only use this if you are cleaning up the Smartnode and want to start over!

rocketpool-cli/service/commands.go

-50
Original file line numberDiff line numberDiff line change
@@ -451,56 +451,6 @@ func RegisterCommands(app *cli.App, name string, aliases []string) {
451451
},
452452
},
453453

454-
{
455-
Name: "export-eth1-data",
456-
Usage: "Exports the execution client (eth1) chain data to an external folder. Use this if you want to back up your chain data before switching execution clients.",
457-
UsageText: "rocketpool service export-eth1-data target-folder",
458-
Flags: []cli.Flag{
459-
cli.BoolFlag{
460-
Name: "force",
461-
Usage: "Bypass the free space check on the target folder",
462-
},
463-
cli.BoolFlag{
464-
Name: "dirty",
465-
Usage: "Exports the execution (eth1) chain data without stopping the client. Requires a second pass (much faster) to sync the remaining files without the client running.",
466-
},
467-
cli.BoolFlag{
468-
Name: "yes, y",
469-
Usage: "Automatically confirm",
470-
},
471-
},
472-
Action: func(c *cli.Context) error {
473-
474-
// Validate args
475-
if err := cliutils.ValidateArgCount(c, 1); err != nil {
476-
return err
477-
}
478-
targetDir := c.Args().Get(0)
479-
480-
// Run command
481-
return exportEcData(c, targetDir)
482-
483-
},
484-
},
485-
486-
{
487-
Name: "import-eth1-data",
488-
Usage: "Imports execution client (eth1) chain data from an external folder. Use this if you want to restore the data from an execution client that you previously backed up.",
489-
UsageText: "rocketpool service import-eth1-data source-folder",
490-
Action: func(c *cli.Context) error {
491-
492-
// Validate args
493-
if err := cliutils.ValidateArgCount(c, 1); err != nil {
494-
return err
495-
}
496-
sourceDir := c.Args().Get(0)
497-
498-
// Run command
499-
return importEcData(c, sourceDir)
500-
501-
},
502-
},
503-
504454
{
505455
Name: "resync-eth1",
506456
Usage: fmt.Sprintf("%sDeletes the main ETH1 client's chain data and resyncs it from scratch. Only use this as a last resort!%s", colorRed, colorReset),

rocketpool-cli/service/service.go

-235
Original file line numberDiff line numberDiff line change
@@ -1633,241 +1633,6 @@ func getConfigYaml(c *cli.Context) error {
16331633
return nil
16341634
}
16351635

1636-
// Export the EC volume to an external folder
1637-
func exportEcData(c *cli.Context, targetDir string) error {
1638-
1639-
// Get RP client
1640-
rp := rocketpool.NewClientFromCtx(c)
1641-
defer rp.Close()
1642-
1643-
// Get the config
1644-
cfg, isNew, err := rp.LoadConfig()
1645-
if err != nil {
1646-
return err
1647-
}
1648-
if isNew {
1649-
return fmt.Errorf("Settings file not found. Please run `rocketpool service config` to set up your Smart Node.")
1650-
}
1651-
1652-
// Make the path absolute
1653-
targetDir, err = filepath.Abs(targetDir)
1654-
if err != nil {
1655-
return fmt.Errorf("Error converting to absolute path: %w", err)
1656-
}
1657-
1658-
// Make sure the target dir exists and is accessible
1659-
targetDirInfo, err := os.Stat(targetDir)
1660-
if os.IsNotExist(err) {
1661-
return fmt.Errorf("Target directory [%s] does not exist.", targetDir)
1662-
} else if err != nil {
1663-
return fmt.Errorf("Error reading target dir: %w", err)
1664-
}
1665-
if !targetDirInfo.IsDir() {
1666-
return fmt.Errorf("Target directory [%s] is not a directory.", targetDir)
1667-
}
1668-
1669-
fmt.Println("This will export your execution client's chain data to an external directory, such as a portable hard drive.")
1670-
fmt.Println("If your execution client is running, it will be shut down.")
1671-
fmt.Println("Once the export is complete, your execution client will restart automatically.")
1672-
fmt.Println()
1673-
1674-
// Get the container prefix
1675-
prefix, err := rp.GetContainerPrefix()
1676-
if err != nil {
1677-
return fmt.Errorf("Error getting container prefix: %w", err)
1678-
}
1679-
1680-
// Get the EC volume name
1681-
executionContainerName := prefix + ExecutionContainerSuffix
1682-
volume, err := rp.GetClientVolumeName(executionContainerName, clientDataVolumeName)
1683-
if err != nil {
1684-
return fmt.Errorf("Error getting execution client volume name: %w", err)
1685-
}
1686-
1687-
if !c.Bool("force") {
1688-
// Make sure the target dir has enough space
1689-
volumeBytes, err := getVolumeSpaceUsed(rp, volume)
1690-
if err != nil {
1691-
fmt.Printf("%sWARNING: Couldn't check the disk space used by the Execution client volume: %s\nPlease verify you have enough free space to store the chain data in the target folder before proceeding!%s\n\n", colorRed, err.Error(), colorReset)
1692-
} else {
1693-
volumeBytesHuman := humanize.IBytes(volumeBytes)
1694-
targetFree, err := getPartitionFreeSpace(rp, targetDir)
1695-
if err != nil {
1696-
fmt.Printf("%sWARNING: Couldn't get the free space available on the target folder: %s\nPlease verify you have enough free space to store the chain data in the target folder before proceeding!%s\n\n", colorRed, err.Error(), colorReset)
1697-
} else {
1698-
freeSpaceHuman := humanize.IBytes(targetFree)
1699-
fmt.Printf("%sChain data size: %s%s\n", colorLightBlue, volumeBytesHuman, colorReset)
1700-
fmt.Printf("%sTarget dir free space: %s%s\n", colorLightBlue, freeSpaceHuman, colorReset)
1701-
if targetFree < volumeBytes {
1702-
return fmt.Errorf("%sYour target directory does not have enough space to hold the chain data. Please free up more space and try again or use the --force flag to ignore this check.%s", colorRed, colorReset)
1703-
}
1704-
1705-
fmt.Printf("%sYour target directory has enough space to store the chain data.%s\n\n", colorGreen, colorReset)
1706-
}
1707-
}
1708-
}
1709-
1710-
// Prompt for confirmation
1711-
fmt.Printf("%sNOTE: Once started, this process *will not stop* until the export is complete - even if you exit the command with Ctrl+C.\nPlease do not exit until it finishes so you can watch its progress.%s\n\n", colorYellow, colorReset)
1712-
if !(c.Bool("yes") || cliutils.Confirm("Are you sure you want to export your execution layer chain data?")) {
1713-
fmt.Println("Cancelled.")
1714-
return nil
1715-
}
1716-
1717-
var result string
1718-
// If dirty flag is used, copies chain data without stopping the eth1 client.
1719-
// This requires a second quick pass to sync the remaining files after stopping the client.
1720-
if !c.Bool("dirty") {
1721-
fmt.Printf("Stopping %s...\n", executionContainerName)
1722-
result, err := rp.StopContainer(executionContainerName)
1723-
if err != nil {
1724-
return fmt.Errorf("Error stopping main execution container: %w", err)
1725-
}
1726-
if result != executionContainerName {
1727-
return fmt.Errorf("Unexpected output while stopping main execution container: %s", result)
1728-
}
1729-
}
1730-
1731-
// Run the migrator
1732-
ecMigrator := cfg.Smartnode.GetEcMigratorContainerTag()
1733-
fmt.Printf("Exporting data from volume %s to %s...\n", volume, targetDir)
1734-
err = rp.RunEcMigrator(prefix+EcMigratorContainerSuffix, volume, targetDir, "export", ecMigrator)
1735-
if err != nil {
1736-
return fmt.Errorf("Error running EC migrator: %w", err)
1737-
}
1738-
1739-
if !c.Bool("dirty") {
1740-
// Restart ETH1
1741-
fmt.Printf("Restarting %s...\n", executionContainerName)
1742-
result, err = rp.StartContainer(executionContainerName)
1743-
if err != nil {
1744-
return fmt.Errorf("Error starting main execution client: %w", err)
1745-
}
1746-
if result != executionContainerName {
1747-
return fmt.Errorf("Unexpected output while starting main execution client: %s", result)
1748-
}
1749-
}
1750-
1751-
fmt.Println("\nDone! Your chain data has been exported.")
1752-
1753-
return nil
1754-
1755-
}
1756-
1757-
// Import the EC volume from an external folder
1758-
func importEcData(c *cli.Context, sourceDir string) error {
1759-
1760-
// Get RP client
1761-
rp := rocketpool.NewClientFromCtx(c)
1762-
defer rp.Close()
1763-
1764-
// Get the config
1765-
cfg, isNew, err := rp.LoadConfig()
1766-
if err != nil {
1767-
return err
1768-
}
1769-
if isNew {
1770-
return fmt.Errorf("Settings file not found. Please run `rocketpool service config` to set up your Smart Node.")
1771-
}
1772-
1773-
// Make the path absolute
1774-
sourceDir, err = filepath.Abs(sourceDir)
1775-
if err != nil {
1776-
return fmt.Errorf("Error converting to absolute path: %w", err)
1777-
}
1778-
1779-
// Get the container prefix
1780-
prefix, err := rp.GetContainerPrefix()
1781-
if err != nil {
1782-
return fmt.Errorf("Error getting container prefix: %w", err)
1783-
}
1784-
1785-
// Check the source dir
1786-
fmt.Println("Checking source directory...")
1787-
ecMigrator := cfg.Smartnode.GetEcMigratorContainerTag()
1788-
sourceBytes, err := rp.GetDirSizeViaEcMigrator(prefix+EcMigratorContainerSuffix, sourceDir, ecMigrator)
1789-
if err != nil {
1790-
return err
1791-
}
1792-
1793-
fmt.Println("This will import execution layer chain data that you previously exported into your execution client.")
1794-
fmt.Println("If your execution client is running, it will be shut down.")
1795-
fmt.Println("Once the import is complete, your execution client will restart automatically.")
1796-
fmt.Println()
1797-
1798-
// Get the volume to import into
1799-
executionContainerName := prefix + ExecutionContainerSuffix
1800-
volume, err := rp.GetClientVolumeName(executionContainerName, clientDataVolumeName)
1801-
if err != nil {
1802-
return fmt.Errorf("Error getting execution client volume name: %w", err)
1803-
}
1804-
1805-
// Make sure the target volume has enough space
1806-
if err != nil {
1807-
fmt.Printf("%sWARNING: Couldn't check the disk space used by the source folder: %s\nPlease verify you have enough free space to import the chain data before proceeding!%s\n\n", colorRed, err.Error(), colorReset)
1808-
} else {
1809-
sourceBytesHuman := humanize.IBytes(sourceBytes)
1810-
volumePath, err := rp.GetClientVolumeSource(executionContainerName, clientDataVolumeName)
1811-
if err != nil {
1812-
err = fmt.Errorf("error getting execution volume source path: %w", err)
1813-
fmt.Printf("%sWARNING: Couldn't check the disk space free on the Docker volume partition: %s\nPlease verify you have enough free space to import the chain data before proceeding!%s\n\n", colorRed, err.Error(), colorReset)
1814-
} else {
1815-
targetFree, err := getPartitionFreeSpace(rp, volumePath)
1816-
if err != nil {
1817-
fmt.Printf("%sWARNING: Couldn't check the disk space free on the Docker volume partition: %s\nPlease verify you have enough free space to import the chain data before proceeding!%s\n\n", colorRed, err.Error(), colorReset)
1818-
} else {
1819-
freeSpaceHuman := humanize.IBytes(targetFree)
1820-
1821-
fmt.Printf("%sChain data size: %s%s\n", colorLightBlue, sourceBytesHuman, colorReset)
1822-
fmt.Printf("%sDocker drive free space: %s%s\n", colorLightBlue, freeSpaceHuman, colorReset)
1823-
if targetFree < sourceBytes {
1824-
return fmt.Errorf("%sYour Docker drive does not have enough space to hold the chain data. Please free up more space and try again.%s", colorRed, colorReset)
1825-
}
1826-
1827-
fmt.Printf("%sYour Docker drive has enough space to store the chain data.%s\n\n", colorGreen, colorReset)
1828-
}
1829-
}
1830-
}
1831-
1832-
// Prompt for confirmation
1833-
fmt.Printf("%sNOTE: Importing will *delete* your existing chain data!%s\n\n", colorYellow, colorReset)
1834-
fmt.Printf("%sOnce started, this process *will not stop* until the import is complete - even if you exit the command with Ctrl+C.\nPlease do not exit until it finishes so you can watch its progress.%s\n\n", colorYellow, colorReset)
1835-
if !(c.Bool("yes") || cliutils.Confirm("Are you sure you want to delete your existing execution layer chain data and import other data from a backup?")) {
1836-
fmt.Println("Cancelled.")
1837-
return nil
1838-
}
1839-
1840-
fmt.Printf("Stopping %s...\n", executionContainerName)
1841-
result, err := rp.StopContainer(executionContainerName)
1842-
if err != nil {
1843-
return fmt.Errorf("Error stopping main execution container: %w", err)
1844-
}
1845-
if result != executionContainerName {
1846-
return fmt.Errorf("Unexpected output while stopping main execution container: %s", result)
1847-
}
1848-
1849-
// Run the migrator
1850-
fmt.Printf("Importing data from %s to volume %s...\n", sourceDir, volume)
1851-
err = rp.RunEcMigrator(prefix+EcMigratorContainerSuffix, volume, sourceDir, "import", ecMigrator)
1852-
if err != nil {
1853-
return fmt.Errorf("Error running EC migrator: %w", err)
1854-
}
1855-
1856-
// Restart ETH1
1857-
fmt.Printf("Restarting %s...\n", executionContainerName)
1858-
result, err = rp.StartContainer(executionContainerName)
1859-
if err != nil {
1860-
return fmt.Errorf("Error starting main execution client: %w", err)
1861-
}
1862-
if result != executionContainerName {
1863-
return fmt.Errorf("Unexpected output while starting main execution client: %s", result)
1864-
}
1865-
1866-
fmt.Println("\nDone! Your chain data has been imported.")
1867-
1868-
return nil
1869-
}
1870-
18711636
// Get the amount of space used by a Docker volume
18721637
func getVolumeSpaceUsed(rp *rocketpool.Client, volume string) (uint64, error) {
18731638
size, err := rp.GetVolumeSize(volume)

0 commit comments

Comments
 (0)