From 4c6f330727b60f7ff37c01842f661a690ab29ef9 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Thu, 31 Jan 2019 18:20:33 +0100 Subject: [PATCH] fix issue with dot folders --- bup-backup.hs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bup-backup.hs b/bup-backup.hs index 3298e02..23e8eb2 100755 --- a/bup-backup.hs +++ b/bup-backup.hs @@ -4,13 +4,14 @@ #! env | BUP_DIR #! haskell | shell-conduit filepath -import Data.List (intersperse) +import Data.List (intersperse) import Data.Conduit.Shell import Data.Conduit.Shell.Segments (strings) import Data.Conduit.Shell.Variadic (variadicProcess) import System.FilePath +-- | regexs for excluded files excluded :: [String] excluded = intersperse "--exclude-rx" [ "/home/rnhmjoj/game/" @@ -20,18 +21,20 @@ excluded = intersperse "--exclude-rx" main :: IO () -main = run (strings (bup "ls") >>= mapM_ backup) +main = run $ mapM_ backup =<< strings (bup "ls") +-- | Finds the path of a backup findPath :: String -> Segment FilePath findPath path = do - files <- strings (bup "ls" path) - if length files /= 1 - then return ("/" final path) - else findPath (path head files) + files <- strings (bup "ls" "-A" path) + if length files == 1 + then findPath (path head files) + else return $ "/" final path where final = concat . drop 2 . splitPath +-- | Runs the backup backup :: String -> Segment () backup name = do path <- findPath (name "latest") @@ -39,5 +42,6 @@ backup name = do bup "save" "-n" name path +-- | Fix for missing execs on NixOS bup :: ProcessType r => String -> r bup = variadicProcess "bup"