There are various ways to back up files in linux and most of them are possible through already onboard applications like rsync and tar. I will demonstrate how to backup files using both, tar and rsync with remote and local destination. I will also show how to restore files in case you need it.
So let's begin with tar. Options and their meanings will be shown below.
Create the archive using tar to a local directory:
c - create a new archive
v - verbose output
p - preserve permissions
z - compression with gzip
f - the filename for the new archive
Extracting the archive using tar from a local directory:
x - create new archive
v - verbose output
p - preserve permissions
z - uncompress with gzip
f - the filename of the archive
If you just need to keep directories in sync. For archiving, tar or rsnapshot would be the better choices.
Sync directories to local mirror with rsync:
v - verbose output
So let's begin with tar. Options and their meanings will be shown below.
Create the archive using tar to a local directory:
[archy@host ~]$ tar -cvpzf backup-homedir.tar.gz --exclude=backup-homedir.tar.gz ./*
options:c - create a new archive
v - verbose output
p - preserve permissions
z - compression with gzip
f - the filename for the new archive
Extracting the archive using tar from a local directory:
[archy@host ~]$ tar -xvpzf backup-homedir.tar.gz -C /path/to/destination
options:x - create new archive
v - verbose output
p - preserve permissions
z - uncompress with gzip
f - the filename of the archive
If you just need to keep directories in sync. For archiving, tar or rsnapshot would be the better choices.
Sync directories to local mirror with rsync:
[archy@host ~]$ rsync -vrlptgoDxhP ./* /backup/$(date +%Y-%m-%d)
Options:v - verbose output
r - copy recursive
l - copy symlinks
p - preserve permissions
t - preserve modification times
g - preserve group permissions
o - preserve owner permissions
o - preserve owner permissions
D - preserve device and special files
x - don't cross filesystem borders
h - human-readable output
P - show progress during transfer and
Sync from Backup Destination:
v - verbose output
Sync from Backup Destination:
h - human-readable output
P - show progress during transfer and
Sync from Backup Destination:
[archy@host ~]$ rsync -vrlptgoDxhP /backup/$(date +%Y-%m-%d)/ ./
Sync directories over ssh: [archy@host ~]$ rsync -vrlptgoDxhPe ssh ./* archy@vault.archyslife.lan:/path/to/destination
Options:v - verbose output
r - copy recursive
l - copy symlinks
p - preserve permissions
t - preserve modification times
g - preserve group permissions
o - preserve owner permissions
o - preserve owner permissions
D - preserve device and special files
x - don't cross filesystem borders
h - human-readable output
P - show progress during transfer and
e - specify remote shellh - human-readable output
P - show progress during transfer and
Sync from Backup Destination:
[archy@host ~]$ rsync -vrlptgoDxhPe ssh archy@vault.archyslife.lan:/path/to/destination ./
Feel free to comment and / or suggest any topics.
Comments
Post a Comment