Download scripts/mysql/restore from azils3/n: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/azils3/n/resolve/main/scripts/mysql/restore
- Command line
-
hf download hf://spaces/azils3/n/scripts/mysql/restore
-
curl -L -o restore https://huggingface.co/spaces/azils3/n/resolve/main/scripts/mysql/restore
1.1 kB
| # The directory where backups are stored | |
| BACKUP_DIRECTORY="/backups" | |
| # Check if a file name was provided as a parameter | |
| if [ $# -eq 0 ]; then | |
| echo "No file name provided. Please provide a file name to check." | |
| exit 1 | |
| fi | |
| # The file name is taken from the first argument provided to the script | |
| file_name="$1" | |
| # Full path to the file | |
| full_file_path="${BACKUP_DIRECTORY}/${file_name}" | |
| # Check if the file exists | |
| if [ -f "$full_file_path" ]; then | |
| echo "File ${file_name} exists." | |
| else | |
| echo "File ${file_name} does not exist." | |
| exit 1 | |
| fi | |
| export MYSQL_USER="${MYSQL_USER}" | |
| export MYSQL_PASSWORD="${MYSQL_PASSWORD}" | |
| export MYSQL_DATABASE="${MYSQL_DATABASE}" | |
| echo "Dropping the database..." | |
| mysql -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -e "DROP DATABASE IF EXISTS \`$MYSQL_DATABASE\`" | |
| echo "Creating a new database..." | |
| mysql -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" -e "CREATE DATABASE \`$MYSQL_DATABASE\`" | |
| echo "Applying the backup to the new database..." | |
| gunzip -c "${full_file_path}" | mysql -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" | |
| echo "Backup applied successfully." | |