Advertisement
Guest User

FlarumAutoUpdate

a guest
Dec 3rd, 2022
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.97 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Name of your flarum database
  4. databases="flarum_forum"
  5.  
  6. # Directory name for temp copy
  7. tempcopydir="tempdir"
  8.  
  9. # Directory where is your flarum folder
  10. flarumdir=/your_path_to/flarum
  11. copyassets="y"
  12.  
  13. # Directory where you want the backup files to be placed
  14. backupdir=/your_path_to/flarum/copy/$tempcopydir
  15.  
  16. # Autoupdate turn on/off
  17. autoupdate="y"
  18.  
  19. # MySQL dump command, use the full path name here
  20. mysqldumpcmd=/usr/bin/mysqldump
  21.  
  22. # MySQL Username and password
  23. userpassword=" --user=databaseuser --password=databasepassword"
  24.  
  25. # MySQL dump options
  26. dumpoptions=" --quick --add-drop-table --add-locks --extended-insert --lock-tables --no-tablespaces"
  27.  
  28. # Unix Commands
  29. gzip=/bin/gzip
  30.  
  31. # Get the Day of the Week (0-6)
  32. DOW=`date +%w`
  33.  
  34. # Create our backup directory if not already there
  35. mkdir -p ${backupdir}
  36. if [ ! -d ${backupdir} ]
  37. then
  38.    echo "Not a directory: ${backupdir}"
  39.    exit 1
  40. fi
  41.  
  42. # Dump all of our databases
  43. echo "Dumping MySQL Database"
  44. for database in $databases
  45. do
  46.    $mysqldumpcmd $userpassword $dumpoptions $database > ${backupdir}/${DOW}-${database}.sql
  47. done
  48.  
  49. # Compress database backup files
  50. echo "Compressing database Files"
  51. for database in $databases
  52. do
  53.    rm -f ${backupdir}/${DOW}-${database}.sql.gz
  54.    $gzip ${backupdir}/${DOW}-${database}.sql
  55. done
  56.  
  57. echo "Copy composer.json and public/assets"
  58. if [ $copyassets = "y" ]
  59. then
  60.    cp composer.json $backupdir/composer.json
  61.    mkdir -p $backupdir/public/assets
  62.    cp -R public/assets $backupdir/public
  63.    echo "Comporessing all files, and copy them to flarum folder"
  64.    tar -czvf Flarum-AutoUpdate.tar.gz $tempcopydir
  65.    pwd
  66. fi
  67.  
  68. echo "List of files and dirs copied."
  69. ls -l ${backupdir}
  70. echo "Autocopy completed!"
  71.  
  72. if [ $autoupdate = "y" ]
  73. then
  74.    echo "Autoupdate turned on.."
  75.    composer update --prefer-dist --no-plugins --no-dev -a --with-all-dependencies
  76.    php flarum migrate
  77.    php flarum cache:clear
  78.    echo "Flarum was copied and updated automatically."
  79. fi
  80. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement