The followingCodeBoth are newlisp. With the help of crontab, the GIT repository and MySQL database are backed up regularly. Because the GIT lab data is stored here.
In fact, newlisp is suitable for O & M scripts.
Git_backup.lsp file:
(Set 'Folder-Name (date-value) 0 "% Y-% m-% d") (println folder-name) (set 'Folder-name2 (date-value)-2880 "% Y-% m-% d ")) (set 'base-path "/opt/cmdon110/BK/git/") (println folder-name2) (make-Dir (append base-path folder-name )) (Exec (APPEND "CP-r/home/git/repositories" base-path folder-name) (if (file? (Append base-path folder-name2) (Exec (APPEND "RM-RF" base-path folder-name2) (Exit)
Mysql_backup.lsp file:
File edit options buffers tools lisp help (set 'Folder-Name (date-value) 0 "% Y-% m-% d") (println folder-name) (set 'Folder-name2 (date-value)-2880 "% Y-% m-% d ")) (set 'base-path "/opt/mongoon110/BK/MySQL/") (println folder-name2) (make-Dir (append base-path folder-name )) (Exec (APPEND "mysqldump-u root-pyour_pwd -- all-databases>" base-path folder-name "/all-database. SQL") (if (file? (Append base-path folder-name2) (Exec (APPEND "RM-RF" base-path folder-name2) (Exit)
Note that the newlisp file operation API cannot easily copy directories, so the Linux Command CP-R is also used here.
In the future, consider writing one by yourself. Or wait for Lutz to add this API?
Crontab Configuration:
50 23 *** newlisp/opt/git_backup.lsp40 23 *** newlisp/opt/mysql_backup.lsp
The premise is that newlisp has been installed in Ubuntu.