Please note that LinuxExchange will be shutting down on December 31st, 2016. Visit this thread for additional information and to provide feedback.

What is the ideal place for saving backups of code, websites, database, etc? /var/backups is reserved for backups of system files. I suppose one can create /var/backup but then users would have to be careful and pay attention to the distinction between backup and backups. Another possibility is to create a new partition and mount it at /backup, but that would be an over-kill. So, any other suggestions? Thanks.

asked 15 Aug '11, 15:06

henok's gravatar image

henok
1112
accept rate: 0%




OVERALL: I would use an external hard drive coupled with an online backup solution like CrashPlan; but you can do everything with rsync and ssh too if you wanted. Many ways to do that task.

The HOW: I use Simple Backup (Debian/Linux Mint/Ubuntu) (sbackup) which stores files incrementally daily with full backups weekly, also using the Logarithmic Purging enabled. Again, many methods, but this is the one I have chosen to use. It works for me, probably will for you, but ultimately it's your call to make on whatever method you decide to use.

The WHAT: If I'm backing up the OS and applications, I use remastersys If I'm backing up the OS, applications, configurations and personal files, I use CloneZilla. If I'm backing up a one or more directories of files, I use Simple Backup.

I also have a custom script which creates, backs up, and tar.gz certain configuration files.

The WHERE:

I backup to 3 places....

1) A 2nd internal hard drive 2) An external hard drive 3) Online Storage space

All of these can be (and are in my case) automated. You could aos do RAID 0+1 as well for the internal drives.

---------------------------------------------------------------------------------------------------------------------

BACKUPS AND RESTORE

---------------------------------------------------------------------------------------------------------------------

Backup aliases

alias backup-bashaliases='sudo cp -f $HOME/$user/.bash_aliases $HOME/$user/.bash_aliases.backup && echo bash_aliases is now backed up'

Backup bashrc

alias backup-bashrc='sudo cp -f $HOME/$user/.bashrc $HOME/$user/.bashrc.backup && echo bashrc is now backed up'

Backup etc

alias backup-etc='sudo mkisofs -J -r -V "etc.backup" -o $HOME/etc.backup.iso /etc && echo the entire etc directory is now backed up to an iso image'

Restore aliases

alias restore-bashaliases='sudo cp -f bash_aliases.backup $HOME/$user/.bash_aliases && echo bash_aliases is now backed up'

Restore bashrc

alias restore-bashrc='sudo cp -f $HOME/$user/.bashrc.backup $HOME/$user/.bashrc && echo bashrc is now restored'

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Backup iptables

alias backup-iptables='sudo iptables-save -c > /$HOME/$user/iptables.rules && sudo iptables-restore < /$HOME/$user/iptables.rules && sudo cp -f /$HOME/$user/iptables.rules /etc/iptables.rules && sleep 3s && sudo rm -f /$HOME/$user/iptables.rules && sudo cp -f /etc/iptables.rules /etc/iptables.rules.backup && echo iptables.rules is now backed up'

Backup ip6tables

alias backup-ip6tables='sudo ip6tables-save -c > /$HOME/$user/ip6tables.rules && sudo ip6tables-restore < /$HOME/$user/ip6tables.rules && sudo cp -f /$HOME/$user/ip6tables.rules /etc/ip6tables.rules && sudo cp -f /etc/ip6tables.rules /etc/ip6tables.rules.backup && sleep 3s && sudo rm -f /$HOME/$user/ip6tables.rules && echo ip6tables.rules is now backed up'

Backup all iptables and ip6tables

alias backup-iptables-all='sudo iptables-save -c > /$HOME/$user/iptables.rules && sudo iptables-restore < /$HOME/$user/iptables.rules && sudo cp -f /$HOME/$user/iptables.rules /etc/iptables.rules && sudo /etc/iptables.rules /etc/iptables.rules.backup && sleep 3s && sudo rm -f /$HOME/$user/iptables.rules && sudo ip6tables-save -c > /$HOME/$user/ip6tables.rules && sudo ip6tables-restore < /$HOME/$user/ip6tables.rules && sudo cp -f /$HOME/$user/ip6tables.rules /etc/ip6tables.rules && sudo /etc/ip6tables.rules /etc/ip6tables.rules.backup && sleep 3s && sudo rm -f /$HOME/$user/ip6tables.rules && echo iptables and ip6tables.rules are both now backed up'

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

restore-iptables

alias restore-iptables='sudo iptables-restore < /etc/iptables.rules.backup && sudo iptables-save -c > $HOME/$user/iptables.rules && sudo iptables-restore < $HOME/$user/iptables.rules && sudo cp -f $HOME/$user/iptables.rules /etc/iptables.rules && sleep 3s && sudo rm -f $HOME/$user/iptables.rules && echo iptables,rules is now restored'

restore-ip6tables

alias restore-ip6tables='sudo ip6tables-restore < /etc/ip6tables.rules.backup && sudo ip6tables-save -c > $HOME/$user/ip6tables.rules && sudo ip6tables-restore < $HOME/$user/ip6tables.rules && sudo cp -f $HOME/$user/ip6tables.rules /etc/ip6tables.rules && sleep 3s && sudo rm -f $HOME/$user/ip6tables.rules && echo ip6tables,rules is now restored'

backup-iptables-all

alias backup-iptables-all='sudo iptables-restore < /etc/iptables.rules.backup && sudo iptables-save -c > $HOME/$user/iptables.rules && sudo iptables-restore < $HOME/$user/iptables.rules && sudo cp -f $HOME/$user/iptables.rules /etc/iptables.rules && sleep 3s && sudo rm -f $HOME/$user/iptables.rules && sudo ip6tables-restore < /etc/ip6tables.rules.backup && sudo ip6tables-save -c > $HOME/$user/ip6tables.rules && sudo ip6tables-restore < $HOME/$user/ip6tables.rules && sudo cp -f $HOME/$user/ip6tables.rules /etc/ip6tables.rules && sleep 3s && sudo rm -f $HOME/$user/ip6tables.ruless && echo iptables.rules and ip6tables.rules are now restored'

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Backup sources.list

alias backup-source='sudo cp -f /etc/apt/sources.list /etc/apt/sources.list.backup && echo sources.list is now backed up'

Restore sources.list

alias restore-source='sudo cp -f /etc/apt/sources.list.backup /etc/apt/sources.list && echo sources.list is now restored'

Backup gnome

alias backup-gnome='gconftool --dump /apps/panel > $HOME/$user/gnome.backup.xml && echo gnome settings are now backed up to $HOME/$user/gnome-back.xml'

Restore gnome

alias restore-gnome='cd $HOME/$user/Desktop && gconftool --load gnome.backup.xml && echo gnome settings are now restored from gnome-back.xml && $HOME/$user'

Backup xorg

alias backup-xorg='sudo cp -f /etc/X11/xorg.conf /etc/X11/xorg.conf.backup && sudo cp -f /usr/share/xresprobe/xorg.conf /usr/share/xresprobe/xorg.conf.backup && echo xorg is now backed up'

Restore xorg

alias restore-xorg='sudo cp -f /etc/X11/xorg.conf.backup /etc/X11/xorg.conf && sudo cp -f /usr/share/xresprobe/xorg.conf.backup /usr/share/xresprobe/xorg.conf && echo xorg is now restores'

Backup denyhosts

alias backup-denyhosts='sudo cp -f /etc/denyhosts.conf /etc/denyhosts.conf.backup && echo denyhosts is now backed up'

Restore denyhosts

alias restore-denyhosts='sudo cp -f /etc/denyhosts.conf.backup /etc/denyhosts.conf && echo denyhosts is now restored'

Backup logrotate

alias backup-logrotate='sudo cp -f /etc/logrotate.conf /etc/logrotate.conf.backup && echo logrotate.conf is now backed up'

Restore logrotate

alias restore-logrotate='sudo cp -f /etc/logrotate.conf.backup /etc/logrotate.conf && echo logrotate.conf is now restored'

Backup interfaces

alias backup-interfaces='sudo cp -f /etc/network/interfaces /etc/network/interfaces.backup && echo the interfaces configuraion file is now backed up'

Restore interfaces

alias restore-interfaces='sudo cp -f /etc/network/interfaces.backup /etc/network/interfaces && echo the interfaces configuration file is now restored'

Backup samba

alias backup-samba='sudo cp -f /etc/samba/smb.conf /etc/samba/smb.conf.backup && echo smb.conf is now backed up'

Restore samba

alias restore-samba='sudo cp -f /etc/samba/smb.conf.backup /etc/samba/smb.conf && echo smb.conf is now restored'

Backup ssh client

alias backup-ssh-client='sudo cp -f /etc/ssh/ssh_config /etc/ssh/ssh_config.backup && echo ssh_config is now backed up'

Restore ssh client

alias restore-ssh-client='sudo cp -f /etc/ssh/ssh_config.backup /etc/ssh/ssh_config && echo ssh_config is now restored'

Backup syslog

alias backup-syslog='sudo cp -f /etc/syslog.conf /etc/syslog.conf.backup && echo syslog.conf is now backed up'

Restore syslog

alias restore-syslog='sudo cp -f /etc/syslog.conf.backup /etc/syslog.conf && echo syslog.conf is now restored'

---------------------------------------------------------------------------------------------------------------------

THESE ALIASES BELOW RELY ON OTHER ALIASES

---------------------------------------------------------------------------------------------------------------------

=====================================================================================================================

============================= ========================================

=====================================================================================================================

alias backup-all='backup-bashaliases && backup-bashrc && backup-iptables && backup-ip6tables && backup-source && backup-gnome && backup-denyhosts && backup-logrotate && backup-interfaces && backup-samba && backup-ssh-client && backup-syslog && backup-xorg && echo all configuration files have been backed up to their respective directories'

alias backup-archive='cd $HOME/$user/Desktop && tar -cvpf configuration-backups-$HOSTNAME-date +%Y%m%d "$HOME/$user/.bash_aliases.backup" "$HOME/$user/.bashrc.backup" "/etc/iptables.rules.backup" "/etc/ip6tables.rules.backup" "/etc/apt/sources.list.backup" "$HOME/$user/gnome.backup.xml" "/etc/X11/xorg.conf.backup" "/usr/share/xresprobe/xorg.conf.backup" "/etc/denyhosts.conf.backup" "/etc/logrotate.conf.backup" "/etc/network/interfaces.backup" "/etc/samba/smb.conf.backup" "/etc/ssh/ssh_config.backup" "/etc/syslog.conf.backup" && echo all configuration files have been backed up in their respective directories as well as being copied to an archive on $HOME/$user/Desktop'

----------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------

alias restore-all='restore-bashaliases && restore-bashrc && restore-iptables && restore-ip6tables && restore-source && restore-gnome && restore-denyhosts && restore-logrotate && restore-interfaces && restore-samba && restore-ssh-client && restore-syslog && restore-xorg s&& echo all configuration files have been restored to their respective directories'

alias restore-archive='cd $HOME/$user/Desktop && sudo tar -xvzpf $1 "/etc/iptables.rules.backup" "/etc/ip6tables.rules.backup" "/etc/apt/sources.list.backup" "$HOME/$user/gnome.backup.xml" "/etc/X11/xorg.conf.backup" "/usr/share/xresprobe/xorg.conf.backup" "/etc/denyhosts.conf.backup" "/etc/logrotate.conf.backup" "/etc/network/interfaces.backup" "/etc/samba/smb.conf.backup" "/etc/ssh/ssh_config.backup" "/etc/syslog.conf.backup && echo all configuration files have been restored to their respective directories'

----------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------

This section is for references only for which files are being backed up.

$HOME/$user/.bash_aliases.backup

$HOME/$user/.bashrc.backup

/etc/iptables.rules.backup

/etc/ip6tables.rules.backup

/etc/apt/sources.list.backup

$HOME/$user/gnome.backup.xml

/etc/X11/xorg.conf.backup

/usr/share/xresprobe/xorg.conf.backup

/etc/denyhosts.conf.backup

/etc/logrotate.conf.backup

/etc/network/interfaces.backup

/etc/samba/smb.conf.backup

/etc/ssh/ssh_config.backup

/etc/syslog.conf.backup

=====================================================================================================================

============================= ========================================

link

answered 16 Aug '11, 11:24

Ron's gravatar image

Ron ♦
9361718
accept rate: 13%

edited 16 Aug '11, 18:06

Although there is a lot of material regarding this available online, I want to highlight a few things for the scenario you specified:

  1. Save in multiple places.
  2. Don't save backups on public servers, especially if the backups concern the servers themselves.
  3. You can mount anything at /backup, it must not necessarily be a partition. Think network locations (samba, sshfs,...).
  4. If the backup's goal is to persist changes, not to save the files themselves, consider using git.
  5. If you want to get creative, create a new user named "backup" with an own /home folder, own permissions and automated jobs.

Please provide us with more details of your current situation and goals if you need more specific help.

link

answered 17 Aug '11, 14:51

Jazz's gravatar image

Jazz ♦
7811312
accept rate: 33%

Look also at revision control. svn, git ...

In addition to offsite backup

link

answered 14 Sep '11, 07:37

daves%20dad's gravatar image

daves dad
1136
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×12
×10

Asked: 15 Aug '11, 15:06

Seen: 4,038 times

Last updated: 14 Sep '11, 07:37

powered by OSQA