Method: ShellHelpers::PathnameExt::Base#backup

Defined in:
lib/shell_helpers/pathname.rb

#backup(suffix: '.old', overwrite: true) ⇒ Object



196
197
198
199
200
201
202
203
# File 'lib/shell_helpers/pathname.rb', line 196

def backup(suffix: '.old', overwrite: true)
	if self.exist?
		filebk=self.append_name(suffix)
		filebk=nonexisting_name if filebk.exist? and !overwrite
		logger.debug "Backup #{self} -> #{filebk}" if respond_to?(:logger)
		FileUtils.mv(self,filebk)
	end
end