Rsnapshot backups en Gnu/Linukso. (1/3)

Rsnapshot

rsnapshot-backup-copias-de-seguridad-tutorial

Rsnapshot backups en Gnu/Linukso. (1/3)
Rsnapshot backups en Gnu/Linukso. (2/3)
Rsnapshot backups en Gnu/Linukso. (3/3)

Realigas Kopioj de sekureco (Backups) Incrementales kaj autom?Ticas Pere de rsync, Uzas malmolajn ligojn por la kopioj incrementales kun kio la kopioj de sekureco okupas malmultan spacon en la disko.

B?Sicamente, La programo realigas unuan kopion kaj en postaj kopioj kopias la novajn kaj modifitajn arkivojn, Kreante Malmolaj ligoj Al la arkivoj kiuj jam exist?An. Aso? Kiu la pluaj kopioj nur okupas la novajn arkivojn.

Arkivo de configuraci?N

/Ktp/rsanpshot.Conf

Uzos Cron Por #a?tomatigi la kopiojn de sekureco.

Scenejo

Servilo de kiu volas realigi kopiojn de pluraj dosierujoj en dosierujo de la sama servilo.

Servilo

Hostname : Servilo
Mastruma sistemo : Ubuntu server 12.04
IP 192.168.1.235

Dosierujoj savi:

/Home
/Ktp
/Var/log

Dosierujo destinas:

/Backup

Kopioj savi: Kopioj #?iu d?Aso oni stokas la ?Ltimos 7 D?Aso
Kopioj #?iu semajno oni stokas la ?Ltimas 4 Semajnoj
Kopioj al la monato oni stokas la ?Ltimos 6 Monatoj
Kopioj al la al?#A? oni stokas la ?Ltimos 5 Al?Vin

  1. Instali rsnapshot
$ #?Viti apt-get install rsnapshot
  1. Agordi rsnapshot Eldonante la arkivon /ktp/rsanpshot.Conf
 $ #?Viti nano /ktp/rsnapshot.Conf

La valoroj kiuj interesas nin estas la sekvaj

  • Snapshot_root Indikas kie ni estas gardontaj la kopiojn de sekureco la stango de la fino estas grava sed ne rekonas la @direcci?n de la dosierujoj. Ne metas sin spacoj se ne kiu sin tabula por la sama raz?N.
			Snapshot_root   /backup/
  • Ne_create_root Oni uzas por indiki al la programo se ?i devas krei la dosierujon destinas #a? ne, Demetas la komenton (#) Se vi realigas la kopion de sekureco en ekstra mekanismo?Ble. Kiel ne estas nia kazo lasas lin komentita.
			#Ne_create_root	
  • Cmd_cp Itinero de la komando cp (Lasas sin kiel #?i tiu)
			Cmd_cp		/bin/cp 
  • Cmd_rm Itinero de la komando rm (Lasas sin kiel #?i tiu)
			Cmd_rm		/bin/rm
  • Cmd_rsync Itinero de la komando rsync (Lasas sin kiel #?i tiu)
			Cmd_rsync		/bin/bin/rsync
  • Cmd_ssh Itinero de la komando ssh sin descomenta se ni iras estas realigi kopiojn de sekureco por reto per ssh (Lasas sin kiel #?i tiu)
			#Cmd_ssh		/usr/bin/ssh
  • Cmd_Du Utilas por uzi rsnapshot kun du por scio la spaco kiu est?N okupante la kopiojn de sekureco. (Demetas sin la komento)
			Cmd_du		/usr/bin/du 
  • cmD_rsnapshot_difF Utilas por vidi la diferencojn kiuj estas inter la malsamaj kopioj de sekureco. (Demetas sin la komento)
			Cmd_rsnapshot_diff		/usr/bin/rsnapshot-diff
  • Retain Utilas por indiki cuantas kopiojn oni stokis en funci?N de la tempo Hourly 6 Indikas ke #?iu Horo Okazas kopio de sekureco kaj oni stokas tiujn de la 6 Finas kopiojn. Por agordi tion markitan #anta?e lasos #?i tiu secci?N de la sekva maniero.
# Retain hourly 6   
Retain daily 7
Retain weekly 4
Retain monthly 6
Retain yearly 5
  • Logfile Utilas por indiki kie #?i tiu la arkivo de log de rsnapshot. (Demetas sin la komento)
			Logfile	/var/log/rsnapshot.Log
  • Backup Utilas por indiki kie Est?N La dosierujoj kiujn ni volas savi en la kopio de sekureco. Despu?s de backup indikas sin la dosierujo savi kaj poste se ni metas Localhost/ Savas lin en la dosierujo indikita en Snapshot_root (/Backup) Se ni metas ekzemple Datumoj/ Lin al ni gardi?Al en /Backup/datumoj/ Por savi la datumojn kiuj volas #?i tiu secci?N resti?Al de la sekva maniero.
 Backup /home/ localhost/
 Backup /ktp/ localhost/
  Backup /var/log/ localhost/ 

Fojo modifitaj #?i tiu paro?Metroj la arkivo de configuraci?N min resti?Al de la sekva maniero. Kadro en #oran?o la paro?Metroj agordi.

#################################################
 # Rsnapshot.Conf - Rsnapshot configuration file #
 #################################################
 # #
 # PLEASE BO AWARE OF THE FOLLOWING RULES: #
 # #
 # This file requires tabs between elements #
 # #
 # Directories require al trailing slash: #
 # Right: /Home/ #
 # Wrong: /Home #
 # #
 #################################################

 #######################
 # CONFIG FILE VERSION #
 #######################

 Config_version 1.2

 ###########################
 # SNAPSHOT ROOT DIRECTORY #
 ###########################

 # All snapshots will bo stored under this root directory.
 #
 Snapshot_root /backup/

 # If ne_create_root is enabled, Rsnapshot will not automatically create the
 # Snapshot_root directory. This is particularly useful if you plugas backing
 # Up to removable duona, Such aso al FireWire or USB drive.
 #
 #Ne_create_root 1

 #################################
 # EXTERNAL PROGRAM DEPENDENCIES #
 #################################

 # LINUKSO USERS: Bo sure to uncomment "Cmd_cp". This gives you ekstra features.
 # EVERYONE ELSE: Leave "Cmd_cp" Commented out for compatibility.
 #
 # See the README file or the man page for #lo?i details.
 #
 Cmd_cp /bin/cp

 # Uncomment this to uzas the rm program instead of the built-in perl routine.
 #
 Cmd_rm /bin/rm

 # Rsync must bo enabled for anything to work. This is the only command that
 # Must bo enabled.
 #
 Cmd_rsync /usr/bin/rsync

 # Uncomment this to enable remote ssh backups over rsync.
 #
 #Cmd_ssh /usr/bin/ssh

 # Comment this out to disable syslog support.
 #
 Cmd_logger /usr/bin/logger

 # Uncomment this to specify the path to "Du" For disk usage checks.
 # If you have an older version of "Du", You may also want to check the
 # "Du_args" Parameter below.
 #
 Cmd_du /usr/bin/du

 # Uncomment this to specify the path to rsnapshot-diff.
 #
 Cmd_rsnapshot_diff /usr/bin/rsnapshot-diff

 # Specify the path to al script (And any optional arguments) To run right
 # Before rsnapshot syncs files
 #
 #Cmd_preexec /path/to/preexec/script

 # Specify the path to al script (And any optional arguments) To run right
 # After rsnapshot syncs files
 #
 #Cmd_postexec /path/to/postexec/script

 # Paths to lvcreate, Lvremove, Mount and umount commands, For uzas with
 # Linukso LVMs.
 #
 #Linux_lvm_cmd_lvcreate /sbin/lvcreate
 #linux_lvm_cmd_lvremove /sbin/lvremove
 #linux_lvm_cmd_mount /bin/mount
 #linux_lvm_cmd_umount /bin/umount
#########################################
 # BACKUP INTERVALS #
 # Must bo unique and in ascending order #
 # I.Kaj. Hourly, Daily, Weekly, Ktp. #
 #########################################

 # Retain hourly 6
 Retain daily 7
 Retain weekly 4
 Retain monthly 6
 Retain yearly 5
############################################
 # SUMA OPTIONS #
 # All plugas optional, With sentiva defaults #
 ############################################

 # Verbose level, 1 Through 5.
 # 1 Quiet Print fatala errors only
 # 2 Default Print errors and warnings only
 # 3 Verbose Spektaklo equivalent shell commands being executed
 # 4 Ekstra Verbose ekstra Spektaklo verbose information
 # 5 Debug mode Everything
 #
 Verbose 2

 # Same aso "Verbose" Above, But controls the amount of #dati?i sent to the
 # Logfile, If one is being used. The default is 3.
 #
 Loglevel 3

 # If you enable this, #Dati?i will bo written to the file you specify. The
 # Amount of #dati?i written is controlled by the "Loglevel" Parameter.
 #
 Logfile	/var/log/rsnapshot.Log

 # If enabled, Rsnapshot will write al lockfile to prevent two instances
 # From running simultaneously (And messing up the snapshot_root).
 # If you enable this, Make sure the lockfile directory is not world
 # Writable. Otherwise anyone hundo prevent the program from running.
 #
 Lockfile /var/run/rsnapshot.Pid

 # By default, Rsnapshot check lockfile, Check if PID is running
 # And if not, Consider lockfile aso stale, Then start
 # Enabling this haltsignalo rsnapshot if PID in lockfile is not running
 #
 #Haltsignalo_on_stale_lockfile 0

 # Default rsync args. All rsync commands have at least these options serio.
 #
 #Rsync_short_args -al
 #rsync_long_args --delete --numeric-ids --relative --delete-excluded

 # Ssh estas ne args passed by default, But you hundo specify some here.
 #
 #Ssh_args -p 22

 # Default arguments for the "Du" Program (For disk space reporting).
 # The GNU version of "Du" Is preferred. See the man page for #lo?i details.
 # If your version of "Du" Doesn't support the -h flag, Try -k flag instead.
 #
 #Du_args -csh

 # If this is enabled, Rsync won't span filesystem partitions within al
 # Backup point. This essentially passes the -x option to rsync.
 # The default is 0 (Off).
 #
 #One_fs 0

 # The include and exclude parameters, If enabled, Simply get passed directly
 # To rsync. If you have multiple include/exclude patterns, Put each one on al
 # Separate line. Please look up the --include and --exclude options in the
 # Rsync man page for #lo?i details on how to specify file name patterns.
 #
 #Include ???
 #Include ???
 #Exclude ???
 #Exclude ???

 # The include_file and exclude_file parameters, If enabled, Simply get
 # Passed directly to rsync. Please look up the --include-from and
 # --Exclude-from options in the rsync man page for #lo?i details.
 #
 #Include_file /path/to/include/file
 #exclude_file /path/to/exclude/file

 # If your version of rsync supports --link-dest, Consider enable this.
 # This is the best way to support special files (FIFOs, Ktp) Cross-platform.
 # The default is 0 (Off).
 #
 #Link_dest 0

 # When sync_first is enabled, It changes the default behaviour of rsnapshot.
 # Normally, When rsnapshot is called with its lowest interval
 # (I.Kaj.: "Rsnapshot hourly"), It will sync files AND rotate the lowest
 # Intervals. With sync_first enabled, "Rsnapshot sync" Handles the file sync,
 # And all interval calls simply rotate files. See the man page for #lo?i
 # Details. The default is 0 (Off).
 #
 #Sync_first 0

 # If enabled, Rsnapshot will move the oldest directory for each interval
 # To [Interval_name].Delete, Then it will remove the lockfile and delete
 # That directory just before it exits. The default is 0 (Off).
 #
 #Uzas_lazy_deletes 0

 # Number of rsync re-tries. If you experience any network problems or
 # Network card issues that tend to #ka?zi ssh to crap-out with
 # "Corrupted MAC on input" Errors, For example, Serio this to al non-zero
 # Value to have the rsync operation re-tried
 #
 #Rsync_numtries 0

 # LVM parameters. Used to backup with creating lvm snapshot before backup
 # And removing it after. This should ensure consistency of #dati?i in some special
 # Geedzigas
 #
 # LVM snapshot(s) Size (Lvcreate --size option).
 #
 #Linux_lvm_snapshotsize 100M

 # Name to bo used when creating the LVM logical volume snapshot(s).
 #
 #Linux_lvm_snapshotname rsnapshot

 # Path to the LVM Volume Groups.
 #
 #Linux_lvm_vgpath /dev

 # Mount point to uzas to temporarily mount the snapshot(s).
 #
 #Linux_lvm_mountpath /path/to/mount/lvm/snapshot/during/backup

 ###############################
 ### BACKUP POINTS / SCRIPTS ###
 ###############################

 # LOCALHOST

 Backup /home/ localhost/
 backup /ktp/ localhost/
 backup /var/log/ localhost/
 #Backup /home/ localhost/
 #backup /ktp/ localhost/
 #backup /usr/loka/ localhost/
 #backup /var/log/rsnapshot localhost/
 #backup /ktp/passwd localhost/
 #backup /home/foo/My Documents/ localhost/
 #backup /foo/trinkejo/ localhost/ one_fs=1, Rsync_short_args=-urltvpog
 #backup_script /usr/loka/bin/backup_pgsql.Sh localhost/postgres/
 # You must serio linux_lvm_* parameters below before using lvm snapshots
 #backup lvm://Vg0/xen-home/ lvm-vg0/xen-home/

 # EXAMPLE.COM
 #backup_script /bin/donu vin "+ Backup of example.Com started at %c" Unused1
 #backup root@example.Com:/Home/ example.Com/  rsync_long_args=--bwlimit=16,exclude=core
 #backup root@example.Com:/Ktp/ example.Com/ exclude=mtab,Exclude=core
 #backup_script ssh root@example.Com "Mysqldump -Al > /Var/db/dump/mysql.Sql" Unused2
 #backup root@example.Com:/Var/db/dump/ example.Com/
 #backup_script /bin/donu vin "+ Backup of example.Com ended at %c" Unused9

  # CVS.SOURCEFORGE.NET
  #backup_script /usr/loka/bin/backup_rsnapshot_cvsroot.Sh rsnapshot.Cvs.Sourceforge.Net/

  # RSYNC.SAMBA.ORG
  #backup rsync://Rsync.Sambo.Org/rsyncftp/ rsync.Sambo.Org/rsyncftp/

 

Por kontroli la #?usta configuraci?N de rsnapshot ekzekutis la sekvan ordonon

$ #?Viti Rsnapshot configtest
Syntax OK

Kiam ?i redonas Syntax OK Estas ke la configuraci?N estas #?usta.

Kontrolis ke ?i funkcias realigante la unuan kopion de sekureco kun la komando.

$ #?Viti rsnapshot daily

Kontrolis ke ?i #krei la dosierujon /Backup/daily.0/Localhost Kiu enhavas la dosierujojn Home, Ktp kaj var/log Kiu queriamos savi.

$ #?Viti ls  -la /backup/daily.0/Localhost

La pr?Ximo d?Al #da?rigi kun nia tutorial de rsnapshot.

Rsnapshot backups en Gnu/Linukso. (1/3)
Rsnapshot backups en Gnu/Linukso. (2/3)
Rsnapshot backups en Gnu/Linukso. (3/3)


About Ignacio Alba Obaya

T?Cnico microinform?Tico kaj formador por la posteno. Amanto de la novaj tecnol?Gias. Administra de GNU/Linukso kaj Vindozo.

5 Comments:

  1. Saluton,

    Por se ?i interesas vin, ElkarBackup estas programaro de backup kiu uzas RSnapshot. Estas b?Sicamente interfaco retejo sur RSnapshot, Sed samtempe multa m?s.

    https://github.com/elkarbackup/elkarbackup

    Adem?s faciligi la gesti?N kaj la recuperaci?N de la backups, En @m?o opini?N lia granda potencialidad estas la #anta?-scripts kaj post-scripts. Kompreneble, Estas libera programaro kaj la c?Mi diras est? Disponebla.

  2. If I am daily backing up al lokalo directory, Say /backup/ into rsnapshot directory /backup_r/, Is there any way of NOT requiring /backup_r/daily.0/Backup/ to bo al copy, But rather al serio of links to /backup, Thereby saving disk space?

    Thanks.

    Lester

  3. I think al good solution is: Start with /backup_r/ empty. Then:

    Mkdir -m 0755 -P /backup_r/daily.0/
    /Bin/cp -al la /backup/ /backup_r/daily.0/ &

    Since /backup/ is already backed up by VPS provider for al few days, Then this should work for filling in #lo?i days. 1a just do not know if there plugas any downsides to this plano?

Leave al Reply