An Easy Way to Backup and or Move Magento

First of all I cant take credit for this. I came across it randomly and I thought the scripts were amazing and thought I would share them here.

Export Script

#!/bin/bash

#####################################################
#          MyProject export script                  #
#####################################################
#
#  To use this script:
#
#  1) Place this script into the MyProject directory you'd like to copy
#  2) Edit the database settings below
#  3) Use the command "./export" or "./export -date"
#
#  This script creates a file called "backup.tar.gz" that can be used
#  to make a new installation of MyProject using the "import" script
#
#  Use "./export -date" to save the file as (TIMESTAMP).tar.gz
#
#  Open the import script for further instructions
#
#  http://magentoadvisor.com
#
#####################################################
#         Keeping this file up to date              #
#####################################################
#
#  Any files modified outside of the directories listed under the
#  comment "Directories to be copied" need to be added to this script
#
#####################################################

#########################
#   Database settings   #
#########################
DBHOST=localhost
DBUSER=advisor_myuser
DBNAME=advisor_myproject
DBPASS=p4ssw0rd

PROJECTNAME=MyProject

#####################################################
#  End configuration options
#####################################################

if [ "$1" = "-date" ]; then
    FILENAME="$PROJECTNAME-$(date +%Y%m%d-%H%M).tar.gz"
else
    FILENAME="backup.tar.gz"
fi

mkdir backup

#############################
# Directories to be created #
#############################
mkdir -p backup/media
mkdir -p backup/app/etc/modules
mkdir -p backup/app/code/local
mkdir -p backup/app/design/adminhtml/default/default
mkdir -p backup/app/design/frontend/default/default
mkdir -p backup/skin/adminhtml/default/default
mkdir -p backup/skin/frontend/default/default
mkdir -p backup/js/jquery
########### End ############

# Config file
cp app/etc/local.xml backup/app/etc/local.xml

# Media directory
cp -r media backup/

# Module declarations
cp app/etc/modules/Yourname_All.xml backup/app/etc/modules/Yourname_All.xml

# Local directories
cp -r app/code/local backup/app/code/
cp -r app/design/adminhtml/default/default backup/app/design/adminhtml/default/
cp -r app/design/frontend/default/default backup/app/design/frontend/default/
cp -r skin/adminhtml/default/default backup/skin/adminhtml/default/
cp -r skin/frontend/default/default backup/skin/frontend/default/
cp -r js/jquery backup/js/

# Dump the database
mysqldump -h $DBHOST -u $DBUSER -p$DBPASS $DBNAME > backup/data.sql

# Create the .tar.gz
tar -zcf $FILENAME ./backup

# Delete the backup directory
rm -rf ./backup

echo "Completed"
echo "$FILENAME has been created"

Import Script

#!/bin/bash

####################################################
#          MyProject installation script           #
####################################################
#
#  This script installs both Magento and MyProject
#
#  To use:
#
#  1) Copy "backup.tar.gz" and this script to chosen directory
#
#  2) Make an empty database and edit the variables below
#
#  3) Run ./import
#
#  4) That's it.  Your magento is ready to go
#
#  http://magentoadvisor.com
#
####################################################

#####################################
#             Variables             #
#####################################

# Set owner of files so apache can execute properly
# "myusername" will typically be your login name
# or /home/<yourname>/public_html
APACHEUSER=myusername
APACHEGROUP=myusername

# Set URL
BASEURL=http://www.yourdomain.com/shop/

# Database Settings
DBHOST=localhost
DBUSER=advisor_myuser
DBNAME=advisor_myproject
DBPASS=p4ssw0rd

# Magento Installation settings
MAGENTOURL=http://www.magentocommerce.com/downloads/assets/1.4.0.1/magento-1.4.0.1.tar.gz
MAGENTOFILE=magento-1.4.0.1.tar.gz

# magento configuration table.  add prefix if your magento is set to use prefixes
CONFIGTABLE=core_config_data

#####################################
#       End Configuration           #
#####################################

#####################################
#       Magento Installation        #
#####################################

wget $MAGENTOURL
tar -zxf $MAGENTOFILE
mv magento/* magento/.htaccess .
chmod -R 0755 .
chmod o+w var var/.htaccess app/etc
chmod -R o+w media
rm -rf downloader/pearlib/cache/* downloader/pearlib/download/*
rm -rf magento/
rm -rf $MAGENTOFILE

#####################################
#    MyProject Installation         #
#####################################

tar -zxf backup.tar.gz
cp -ar backup/* .
rm -rf backup/

#####################################
#      app/etc/local.xml            #
#####################################

USERNAMEREGX='s/<username><!\[CDATA\[.*\]\]><\/username>/<username><![CDATA['$DBUSER']]><\/username>/g'
PASSWORDREGX='s/<password><!\[CDATA\[.*\]\]><\/password>/<password><![CDATA['$DBPASS']]><\/password>/g'
DBNAMEREGX='s/<dbname><!\[CDATA\[.*\]\]><\/dbname>/<dbname><![CDATA['$DBNAME']]><\/dbname>/g'

sed -i $USERNAMEREGX app/etc/local.xml
sed -i $PASSWORDREGX app/etc/local.xml
sed -i $DBNAMEREGX app/etc/local.xml

######################################
#     Import DB from data.sql        #
######################################

# we need to edit web/unsecure/baseurl in __core_config_data__
QUERY="update "$CONFIGTABLE" set "$CONFIGTABLE".value = '"$BASEURL"' where path = 'web/unsecure/base_url' or path = 'web/secure/base_url'"
# just append the update to the end of data.sql
echo $QUERY >> data.sql;
mysql -h $DBHOST -u $DBUSER -p$DBPASS $DBNAME < data.sql
rm -f ./data.sql

######################################
#     End                            #
######################################

chown -R $APACHEUSER:$APACHEGROUP .

echo "Installation complete.  Delete backup.tar.gz"

And to checkout the tutorial go here. I would like to thank Brady Matthews for this awesome tutorial.