Compress files inside directory

go directory:

cd /var/www/yourfile/

zip -r .

import sql to database

mysql -u user -pyourpassword yourdatabase < your-file-db.sql

Compress and decompress folder

For compressing:

tar -cvzf tarballname.tar.gz itemtocompress

and for decompression:

tar xzvf file.tar.gz

Export database settings

mysqldump -u root -p <database> > /data/raidpsbkp2.sql
with procedures and functions
mysqldump -u root -p -R <database> > /data/raidpsbkp2.sql
//ignore views
mysqldump -u root -p -R --ignore-table=dps.vw_tour --ignore-table=dps.vw_user_booking <database> > /data/raidpsbkp2.sql

//custom tables
mysqldump -u root -p -R --skip-triggers dps photo photo_upload photocategory photocategoryrelation > /data/dpscustomtablesoct.sql

//ignoring triggers and data
mysqldump -u root -p -R --skip-triggers --no-data <database> > /data/raidpsbkp2.sql
//ignoring triggers
mysqldump -u root -p -R --no-create-info --skip-triggers <database> > /data/raidpsbkp2.sql
//stored procedures and triggers
mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt <database> > outputfile.sql

//no triggers, no data, no info

mysqldump -u root -p -R --database <database> --skip-opt --routines --no-create-info --no-data --no-create-db --skip-triggers > /var/www/raidpsproc2

Export all database to one file

mysqldump -u root -p --all-databases > alldb.sql

Compress sql file

gzip -9 /data/yourdatabase.sql

Send from host to other server

scp -r foo

Give permissions 755 to files inside folder

First go to folder:

cd /yourfolder/

then give permissions:

chmod -R 755 *

Change owner/group to file inside folder

First go to folder:

cd /yourfolder/

then give permissions:

chown -R www-data:www-data *

Remove all files inside folder

go to folder

rm -rf /yourfolder/*

Backup files of your server

sudo tar -cvpzf backup.tar.gz --exclude=/swapfile --exclude=/backup.tar.gz --one-file-system /


sudo tar -cpzf “$backupfilename”
–exclude=/home/$USER/error.log /

Once the command above has finished its run, look for the backup.tar.gz file inside the / folder and save it to an external file system. If ever you lose some files that need to be restored, just run the following command to restore them:

sudo tar -xvpzf /path/to/backup.tar.gz -C /restore/location --numeric-owner