Skip to content

Commit

Permalink
fix: Target the whole data directory in save/restore state command
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed Nov 20, 2024
1 parent 2e6c515 commit 0ad8a1c
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions lib/commands/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,17 @@ import { runCommand } from "./docker"
export function saveState(): Cypress.Chainable<string> {
const snapshot = Math.random().toString(36).substring(7)

// DB
runCommand(`cp /var/www/html/data/owncloud.db /var/www/html/data/owncloud.db-${snapshot}`)

// Data
runCommand(`rm /var/www/html/data/data-${snapshot}.tar`, { failOnNonZeroExit: false })
runCommand(`tar cf /var/www/html/data/data-${snapshot}.tar .`)
runCommand(`rm /var/www/html/data-${snapshot}.tar`, { failOnNonZeroExit: false })
runCommand(`tar cf /var/www/html/data-${snapshot}.tar ./data`)

cy.log(`Created snapshot ${snapshot}`)

return cy.wrap(snapshot)
}

export function restoreState(snapshot: string = 'init') {
// DB
runCommand(`cp /var/www/html/data/owncloud.db-${snapshot} /var/www/html/data/owncloud.db`)

// Data
runCommand(`rm -vfr $(tar --exclude='*/*' -tf '/var/www/html/data/data-${snapshot}.tar')`)
runCommand(`tar -xf '/var/www/html/data/data-${snapshot}.tar'`)
runCommand(`rm -vfr ./data/*`)
runCommand(`tar -xf '/var/www/html/data-${snapshot}.tar'`)

cy.log(`Restored snapshot ${snapshot}`)
}

0 comments on commit 0ad8a1c

Please sign in to comment.