14const mbpMcSavesDir = pathDownJoin(envHome!, `/Library/Application Support/minecraft/saves`) 15const mbpMcSavesDirDisplay = `~/Library/Application Support/minecraft/saves` 17const worldManifestCmd = ['sh', '-c', 'cd /data/world && find . -type f -printf "%P %s %T@\\n" | sort | md5sum'] 19export const mcbackup = async (lastRunData?: {worldHash?: string}) => { 26 const {podName, containerName} = podInfo 28 const worldHash = await doKubeExecCapture({cmdA: worldManifestCmd, podName, containerName, isQuiet: true}) 29 if (lastRunData?.worldHash && worldHash === lastRunData.worldHash) { 30 console.log(chalkGray(`world unchanged since last backup, skipping download`)) 34 const localWorldName = luxNow().toFormat('yyLLdd') 36 await kubeCpDown({podName, containerName, fromRemotePath: '/data/world/', 39 console.log(chalkGreen(`world backed up (hash changed)`)) 42mcbackup.cliDescript = `backup world to ${mbpMcSavesDirDisplay}` 44export const mcrestore = async () => { 49 const {readdirSync} = await import('fs') 50 const backupDirs = readdirSync(mbpMcSavesDir, {withFileTypes: true}) 51 .filter(dirent => dirent.isDirectory()) 52 .map(dirent => dirent.name) 53 .filter(name => /^\d{6}$/.test(name)) 59 const mostRecentBackup = backupDirs[0] 60 console.log(`Restoring from backup: ${mostRecentBackup}`) 64 const {podName, containerName} = podInfo 69 fromLocalPath: `${mbpMcSavesDir}/${mostRecentBackup}/.`, 70 toRemotePath: '/data/world' 73 await eptKubeCli([cluster_name, 'delete', 'pod', podName]) 75 console.log('Restore complete!') 77mcrestore.cliDescript = `restore world from ${mbpMcSavesDirDisplay}`