From 6e3fbd482904fa902dfac5b45e145394b0be0b07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98ens-ftricomi=E2=80=99?= Date: Mon, 12 Aug 2024 11:38:58 +0100 Subject: [PATCH] added timestamp to backup file --- pipelines/nextflow/workflows/short_read.nf | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pipelines/nextflow/workflows/short_read.nf b/pipelines/nextflow/workflows/short_read.nf index d8d6fff..7fc639d 100644 --- a/pipelines/nextflow/workflows/short_read.nf +++ b/pipelines/nextflow/workflows/short_read.nf @@ -20,6 +20,8 @@ nextflow.enable.dsl=2 import java.nio.file.* import java.nio.file.attribute.BasicFileAttributes +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter // Show help message params.help = false @@ -121,16 +123,20 @@ workflow.onComplete { def outDir = Paths.get(params.outDir) Files.newDirectoryStream(outDir, "*").each { path -> - deleteRecursively(path) + if (!path.toString().endsWith(".gz")) { + deleteRecursively(path) + } } - log.info "Cleaning process completed successfully." } catch (Exception e) { log.error "Exception occurred while executing cleaning command: ${e.message}", e } } if (params.backupDB) { - def backupFilePath = "${params.outDir}/${params.transcriptomic_dbname}_backup.sql" + //def backupFilePath = "${params.outDir}/${params.transcriptomic_dbname}_backup.sql" + // Generate a timestamp + def timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")) + def backupFilePath = "${params.outDir}/${params.transcriptomic_dbname}_backup_${timestamp}.sql" def gzipFilePath = "${backupFilePath}.gz" // Define the database backup command as a list of arguments