Re-arrange backup tasks to avoid holding db session open for too long.